From cfe828723ca4c7f202a68f445acbb89beea4c8c6 Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Mon, 11 Sep 2023 16:09:55 +0530 Subject: [PATCH] updated unit test for ssh --- spectrocloud/resource_ssh_key_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spectrocloud/resource_ssh_key_test.go diff --git a/spectrocloud/resource_ssh_key_test.go b/spectrocloud/resource_ssh_key_test.go new file mode 100644 index 00000000..391e007d --- /dev/null +++ b/spectrocloud/resource_ssh_key_test.go @@ -0,0 +1,24 @@ +package spectrocloud + +import ( + "testing" +) + +func TestToSSHKey(t *testing.T) { + // Create a sample ResourceData object + d := resourceSSHKey().TestResourceData() + name := "testSSHName" + sshKey := "ssh-rsa AAAA6IEQhI1QLiicHLO5a== teerf2021" + d.Set("name", name) + d.Set("ssh_key", sshKey) + + result := toSSHKey(d) + + if result.Metadata.Name != name { + t.Errorf("Expected Metadata Name to be %s, but got %s", name, result.Metadata.Name) + } + + if result.Spec.PublicKey != sshKey { + t.Errorf("Expected Spec PublicKey to be %s, but got %s", sshKey, result.Spec.PublicKey) + } +}