// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
	"os"
	"testing"

	"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource

func TestAccDataSourceIosxeEEM(t *testing.T) {
	if os.Getenv("IOSXE1715") == "" {
		t.Skip("skipping test, set environment variable IOSXE1715")
	}
	var checks []resource.TestCheckFunc
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "environment_variables.0.name", "IOSXE_TEST_VAR"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "environment_variables.0.value", "test_pass"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "session_cli_username", "test_user"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "session_cli_username_privilege", "15"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "history_size_events", "25"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "history_size_traps", "25"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "directory_user_policy", "test/test_path"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "scheduler_applet_thread_class_default", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "scheduler_applet_thread_class_number", "1"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "detector_rpc_max_sessions", "8"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "detector_routing_bootup_delay", "2"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.name", "test_applet_10"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.authorization", "bypass"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.class", "A"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.description", "test describing applet"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_cli_pattern", "shutdown"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_cli_sync", "no"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_cli_skip", "no"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.actions.0.name", "10"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.actions.0.cli_command", "enable"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_watchdog_time", "1800"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_watchdog_name", "test_time"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_watchdog_maxrun", "10"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_watchdog_ratelimit", "10"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_cron_entry", "0 12 * * 1-5"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_cron_name", "test_time"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_cron_maxrun", "10"))
	checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_eem.test", "applets.0.event_timer_cron_ratelimit", "10"))
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t) },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			{
				Config: testAccDataSourceIosxeEEMConfig(),
				Check:  resource.ComposeTestCheckFunc(checks...),
			},
		},
	})
}

// End of section. //template:end testAccDataSource

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
// End of section. //template:end testPrerequisites

// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig

func testAccDataSourceIosxeEEMConfig() string {
	config := `resource "iosxe_eem" "test" {` + "\n"
	config += `	environment_variables = [{` + "\n"
	config += `		name = "IOSXE_TEST_VAR"` + "\n"
	config += `		value = "test_pass"` + "\n"
	config += `	}]` + "\n"
	config += `	session_cli_username = "test_user"` + "\n"
	config += `	session_cli_username_privilege = 15` + "\n"
	config += `	history_size_events = 25` + "\n"
	config += `	history_size_traps = 25` + "\n"
	config += `	directory_user_policy = "test/test_path"` + "\n"
	config += `	scheduler_applet_thread_class_default = true` + "\n"
	config += `	scheduler_applet_thread_class_number = 1` + "\n"
	config += `	detector_rpc_max_sessions = 8` + "\n"
	config += `	detector_routing_bootup_delay = 2` + "\n"
	config += `	applets = [{` + "\n"
	config += `		name = "test_applet_10"` + "\n"
	config += `		authorization = "bypass"` + "\n"
	config += `		class = "A"` + "\n"
	config += `		description = "test describing applet"` + "\n"
	config += `		event_cli_pattern = "shutdown"` + "\n"
	config += `		event_cli_sync = "no"` + "\n"
	config += `		event_cli_skip = "no"` + "\n"
	config += `		actions = [{` + "\n"
	config += `			name = "10"` + "\n"
	config += `			cli_command = "enable"` + "\n"
	config += `		}]` + "\n"
	config += `		event_timer_watchdog_time = 1800` + "\n"
	config += `		event_timer_watchdog_name = "test_time"` + "\n"
	config += `		event_timer_watchdog_maxrun = 10` + "\n"
	config += `		event_timer_watchdog_ratelimit = 10` + "\n"
	config += `		event_timer_cron_entry = "0 12 * * 1-5"` + "\n"
	config += `		event_timer_cron_name = "test_time"` + "\n"
	config += `		event_timer_cron_maxrun = 10` + "\n"
	config += `		event_timer_cron_ratelimit = 10` + "\n"
	config += `	}]` + "\n"
	config += `}` + "\n"

	config += `
		data "iosxe_eem" "test" {
			depends_on = [iosxe_eem.test]
		}
	`
	return config
}

// End of section. //template:end testAccDataSourceConfig
