From 0177a962a3e23e2248f7d1d0c6f2c7851da79479 Mon Sep 17 00:00:00 2001 From: Xeckt Date: Fri, 21 Jun 2024 15:31:58 +0100 Subject: [PATCH] change test_readsshhostkeypublicfiles "line" args struct field to "content" This aims to make the test more obvious that this is the content going into the temporary file Signed-off-by: Xeckt --- sztp-agent/pkg/secureagent/utils_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sztp-agent/pkg/secureagent/utils_test.go b/sztp-agent/pkg/secureagent/utils_test.go index d8d3ad04..0f37193c 100644 --- a/sztp-agent/pkg/secureagent/utils_test.go +++ b/sztp-agent/pkg/secureagent/utils_test.go @@ -126,7 +126,7 @@ func Test_linesInFileContains(t *testing.T) { func Test_readSSHHostKeyPublicFiles(t *testing.T) { type args struct { file string - line string + content string keyType string } tests := []struct { @@ -138,7 +138,7 @@ func Test_readSSHHostKeyPublicFiles(t *testing.T) { name: "Test OK line in files no comment", args: args{ file: "/tmp/test.pub", - line: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR", + content: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR", keyType: "ssh-ed25519", }, want: []publicKey{{Type: "ssh-ed25519", Data: "AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR"}}, @@ -147,7 +147,7 @@ func Test_readSSHHostKeyPublicFiles(t *testing.T) { name: "Test OK line in files with comment", args: args{ file: "/tmp/test.pub", - line: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR comment", + content: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR comment", keyType: "ssh-ed25519", }, want: []publicKey{{Type: "ssh-ed25519", Data: "AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR"}}, @@ -156,7 +156,7 @@ func Test_readSSHHostKeyPublicFiles(t *testing.T) { name: "Test too many parts in file", args: args{ file: "/tmp/test.pub", - line: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR comment error", + content: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR comment error", keyType: "ssh-ed25519", }, want: []publicKey{{Type: "ssh-ed25519", Data: "AAAAC3NzaC1lZDI1NTE5AAAAID0mjQXlOvkM2HO5vTrSOdHOl3BGOqDiHrx8yYdbP8xR"}}, @@ -164,24 +164,24 @@ func Test_readSSHHostKeyPublicFiles(t *testing.T) { { name: "Test not enough parts in file", args: args{ - file: "/tmp/test.pub", - line: "ssh-ed25519", + file: "/tmp/test.pub", + content: "ssh-ed25519", }, want: []publicKey{}, }, { name: "Test file doesn't exist", args: args{ - file: "/tmp/test.pub", - line: "", + file: "/tmp/test.pub", + content: "", }, want: []publicKey{}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if tt.args.line != "" { - createTempTestFile(tt.args.file, tt.args.line, true) + if tt.args.content != "" { + createTempTestFile(tt.args.file, tt.args.content, true) } if got := readSSHHostKeyPublicFiles(tt.args.file); !reflect.DeepEqual(got, tt.want) { t.Errorf("readSSHHostKeyPublicFiles() = %v, want %v", got, tt.want)