connect_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package test
  2. import (
  3. "testing"
  4. "xg_dba/api"
  5. connect "xg_dba/internal/services/connect"
  6. system "xg_dba/internal/services/system"
  7. )
  8. func TestConnectInfo(t *testing.T) {
  9. connectInfo := api.ConnectInfoRequest{
  10. Id: "1",
  11. Ssh: api.SshInfo{
  12. Username: "gtong",
  13. Password: "845895",
  14. Host: "127.0.0.1",
  15. Port: "22",
  16. },
  17. Db: api.DbInfo{
  18. User: "SYSDBA",
  19. Password: "SYSDBA",
  20. Port: "5236",
  21. Database: "test",
  22. },
  23. }
  24. localPath := "C:\\Program_GT\\Code\\Go\\Work\\xugu\\xg_dba\\config/" + connectInfo.Ssh.Host + "/" + connectInfo.Ssh.Host + ".toml"
  25. if err := connect.SetConnectInfo_service(connectInfo, localPath); err != nil {
  26. t.Errorf("SetConnectInfo_service failed: %v", err)
  27. }
  28. }
  29. func TestGetServerInfo(t *testing.T) {
  30. saveFilePath := "C:\\Program_GT\\Code\\Go\\Work\\xugu\\xg_dba\\config\\test\\"
  31. connectInfo := api.ConnectInfoRequest{
  32. Id: "1",
  33. Ssh: api.SshInfo{
  34. Username: "gtong",
  35. Password: "845895",
  36. Host: "127.0.0.1",
  37. Port: "22",
  38. },
  39. }
  40. if err := system.SetSystemInfo_service(connectInfo, saveFilePath); err != nil {
  41. t.Errorf("SetConnectInfo_service failed: %v", err)
  42. }
  43. }