# agridatasets - A Comprehensive Collection of Agricultural and Agronomic Datasets
# Version 0.1.1
# Copyright (C) 2026 Renzo Caceres Rossi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# view_datasets_agridatasets

library(testthat)
library(agridatasets)

test_that("view_datasets_agridatasets works when package is loaded", {
  result <- view_datasets_agridatasets()
  expect_type(result, "character")
  expect_true(length(result) > 0)
})

test_that("view_datasets_agridatasets prints correct message", {
  output <- capture_messages(view_datasets_agridatasets())
  expect_match(
    output[1],
    "Datasets available in the 'agridatasets' package:",
    fixed = TRUE
  )
})

test_that("view_datasets_agridatasets returns expected datasets", {
  datasets <- view_datasets_agridatasets()
  expected_datasets <- c(
    "bamboo_growth",
    "cows_insemination",
    "earthworm_population",
    "earthworm_crop_soils",
    "rabbit_body_mass",
    "rice_wheat_production",
    "timber_genetics",
    "corn_hybrid_density",
    "eucalyptus_progenies",
    "orange_rootstocks",
    "soybean_cultivars",
    "alfalfa_soil",
    "toxin_lethal_dose",
    "idn_rice_farms",
    "soil_munsell_minerals",
    "soil_munsell_colors",
    "us_state_soils",
    "red_wine_quality",
    "cotton_pesticide",
    "willow_cutting_yield",
    "plant_growth_regulator",
    "blackgrass_herbicide",
    "ladybird_fungus",
    "nitrofen_toxicity",
    "black_duck_survival",
    "potato_scab_sulfur",
    "eelworm_fumigation",
    "apple_canker",
    "carrot_fly_infestation",
    "strawberry_cross_disease",
    "cork_tree_direction",
    "egg_weight_daily",
    "fungicide_latin_square",
    "wheat_splitsplit",
    "seed_germination",
    "lamb_births",
    "wheat_bunt",
    "cauliflower_growth",
    "cowpea_maize_yield",
    "strawberry_yield",
    "turnip_density",
    "apple_uniformity",
    "grape_uniformity",
    "peach_uniformity",
    "tomato_uniformity",
    "carrot_insecticide",
    "pig_weight_gain",
    "broiler_growth",
    "hawaii_tree_growth",
    "hawaii_plant_size",
    "biological_control",
    "pollen_removal",
    "river_deforestation",
    "kiwi_crop_design",
    "avocado_us_sale",
    "budworm_pyrethroid",
    "cattle_butterfat",
    "fish_feeding",
    "guinea_pig_sleep",
    "bird_grazing",
    "coffee_production",
    "coffee_composition",
    "arabica_soil",
    "arabica_temp",
    "arabica_terrain",
    "arabica_water",
    "robusta_soil",
    "robusta_temp",
    "robusta_terrain",
    "robusta_water",
    "tomato_insecticides"


  )
  # Check if all expected datasets are present
  missing_datasets <- setdiff(expected_datasets, datasets)
  expect_true(
    length(missing_datasets) == 0,
    info = paste("Missing datasets:", paste(missing_datasets, collapse = ", "))
  )
})
