package executor

import (
	"testing"
	"wdd.io/agent-go/assert"
	"wdd.io/agent-go/register"
)

var agentOP = &AgentOsOperator{
	InstallCommandPrefix: []string{
		"yum", "install", "-y",
	},
	RemoveCommandPrefix: []string{"yum", "remove", "-y"},
	CanAccessInternet:   true,
	IsOsTypeUbuntu:      false,
	IsOsTypeCentOS:      true,
	IsOsTypeEuler:       true,
	IsAgentInnerWall:    true,
	AgentArch:           "amd64",
	AgentOSReleaseCode:  "focal",
	AgentServerInfo: &register.AgentServerInfo{
		ServerName:     "",
		ServerIPPbV4:   "",
		ServerIPInV4:   "10.250.0.147",
		ServerIPPbV6:   "",
		ServerIPInV6:   "",
		Location:       "",
		Provider:       "",
		ManagePort:     "",
		CPUCore:        "",
		CPUBrand:       "",
		OSInfo:         "",
		OSKernelInfo:   "",
		TCPControl:     "",
		Virtualization: "",
		IoSpeed:        "",
		MemoryTotal:    "",
		DiskTotal:      "",
		DiskUsage:      "",
		Comment:        "",
		MachineID:      "",
		AgentVersion:   "",
		TopicName:      "",
	},
	OssOfflinePrefix: "http://10.250.0.100:9000/octopus/",
}

func TestBaseFunc(t *testing.T) {

	//command := "DISABLE_SELINUX"
	//command := "installDocker"
	//command := "installDockerCompose"
	command := "installHarbor"

	funcArgs := []string{
		"10.250.0.147",
		"",
		"",
		"",
	}

	//agentOP.Exec("shutdownFirewall")
	//agentOP.Exec("modifyHostname")
	//agentOP.Exec("disableSwap")
	//agentOP.Exec("enableSwap")
	//agentOP.Exec("removeDocker")
	//agentOP.Exec("installDocker", "20")
	//agentOP.Exec("removeDockerCompose")
	//agentOP.Exec("installDockerCompose")
	//agentOP.Exec("installHelm")
	//agentOP.Exec("installHarbor")
	//agentOP.Exec("chronyToMaster", "192.168.0.8")
	//agentOP.Exec("installZSH")
	//agentOP.Exec("ok")

	exec, strings := agentOP.Exec(command, funcArgs...)
	assert.Equal(t, exec, true, "exec should be true!")
	t.Logf("[%s] exec result are %s", command, strings)

}
