system_test.go 998 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package test
  2. import (
  3. "fmt"
  4. "testing"
  5. "xg_dba/api"
  6. "xg_dba/internal/global"
  7. services "xg_dba/internal/services/system"
  8. _ "xg_dba/pkg/xugu"
  9. )
  10. func TestGetServerInfo(t *testing.T) {
  11. saveFilePath := "C:\\Program_GT\\Code\\Go\\Work\\xugu\\xg_dba\\config\\test\\"
  12. connectInfo := api.ServerInfoRequest{
  13. // Id: "1",
  14. Username: "gtong",
  15. Password: "845895",
  16. Host: "127.0.0.1",
  17. Port: "22",
  18. }
  19. connectInfo2 := api.ServerInfoRequest{
  20. // Id: "1",
  21. Username: "root",
  22. Password: "cdyanfa@2024",
  23. Host: "10.28.25.113",
  24. Port: "22",
  25. }
  26. progressChan := make(chan string)
  27. go func() {
  28. for progress := range progressChan {
  29. fmt.Println("Progress:", progress)
  30. }
  31. }()
  32. progressID := global.Progress.CreateProgress()
  33. if err := services.SetSystemInfo_service([]api.ServerInfoRequest{
  34. connectInfo,
  35. connectInfo2,
  36. }, saveFilePath, progressID); err != nil {
  37. t.Errorf("SetConnectInfo_service failed: %v", err)
  38. }
  39. }
  40. func TestGeDb(t *testing.T) {
  41. services.GetDb()
  42. }