From 18d67f7ef41d048a679236a2210d4a8dc2760944 Mon Sep 17 00:00:00 2001 From: wubijie Date: Wed, 6 Nov 2024 09:55:23 +0800 Subject: [PATCH] Test the connectivity of the new SSHD configuration --- .../server/service/configinstance_test.go | 16 +++++++++++ configmanage/server/service/sshd_test.go | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/configmanage/server/service/configinstance_test.go b/configmanage/server/service/configinstance_test.go index e6121591..ed136584 100644 --- a/configmanage/server/service/configinstance_test.go +++ b/configmanage/server/service/configinstance_test.go @@ -103,3 +103,19 @@ func TestConfigInstanceTypeSSH_Add(t *testing.T) { os.Exit(-1) } } + +func TestConfigInstanceTypeSSHD_Add(t *testing.T) { + ci := &ConfigInstance{ + UUID: uuid.New().String(), + Type: global.SSHD, + Description: "test-SSHD-description", + BatchIds: []int{6}, + DepartIds: []int{60}, + Nodes: []string{"44444444-5f8e-42df-b2d0-49bf55cfeb56"}, + } + err := ci.Add() + if err != nil { + fmt.Printf("Add() error = %v, want nil", err) + os.Exit(-1) + } +} diff --git a/configmanage/server/service/sshd_test.go b/configmanage/server/service/sshd_test.go index 6d43c336..f1d5e03e 100644 --- a/configmanage/server/service/sshd_test.go +++ b/configmanage/server/service/sshd_test.go @@ -1 +1,29 @@ package service + +import ( + "encoding/json" + "fmt" + "os" + "testing" + + "github.com/google/uuid" +) + +func TestSSHDConfig_Record(t *testing.T) { + // 设置测试数据 + sdc := &SSHDConfig{ + UUID: uuid.New().String(), + ConfigInfoUUID: "4d415c77-5a3d-45fb-a221-67dba74db56d", + Content: json.RawMessage(`{"test": "test"}`), + Path: "/ssh", + Name: "ssh.txt", + IsActive: false, + } + + // 调用被测试的函数 + err := sdc.Record() + if err != nil { + fmt.Printf("record error: %s\n", err) + os.Exit(-1) + } +} -- Gitee