Fix some lint and vet issues

This commit is contained in:
Pim van Pelt
2025-08-28 21:17:37 +02:00
parent 7b3639ad69
commit 105a245239
10 changed files with 47 additions and 41 deletions

View File

@@ -12,7 +12,7 @@ import (
func TestGenerateKeys(t *testing.T) {
tmpDir := t.TempDir()
// Create test directories
keyDir := filepath.Join(tmpDir, "keys")
err := os.MkdirAll(keyDir, 0755)
@@ -23,7 +23,7 @@ func TestGenerateKeys(t *testing.T) {
// Create test config
key1Path := filepath.Join(keyDir, "test-log-1.key")
key2Path := filepath.Join(keyDir, "test-log-2.key")
configContent := `logs:
- shortname: "test-log-1"
secret: "` + key1Path + `"
@@ -84,7 +84,7 @@ func TestGenerateKeys(t *testing.T) {
if err != nil {
t.Fatal(err)
}
perm := info.Mode().Perm()
expected := os.FileMode(0600)
if perm != expected {
@@ -94,13 +94,13 @@ func TestGenerateKeys(t *testing.T) {
func TestGenerateKeysExistingKey(t *testing.T) {
tmpDir := t.TempDir()
// Create existing key file
keyPath := filepath.Join(tmpDir, "existing.key")
existingContent := `-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIExistingKeyContent
-----END EC PRIVATE KEY-----`
err := os.WriteFile(keyPath, []byte(existingContent), 0600)
if err != nil {
t.Fatal(err)
@@ -133,9 +133,9 @@ MHcCAQEEIExistingKeyContent
func TestGenerateKeysWithoutWriteFlag(t *testing.T) {
tmpDir := t.TempDir()
keyPath := filepath.Join(tmpDir, "test.key")
configContent := `logs:
- shortname: "test-log"
secret: "` + keyPath + `"`
@@ -157,11 +157,11 @@ func TestGenerateKeysWithoutWriteFlag(t *testing.T) {
func TestGenerateKeysCreateDirectory(t *testing.T) {
tmpDir := t.TempDir()
// Key path with non-existent directory
keyDir := filepath.Join(tmpDir, "subdir", "keys")
keyPath := filepath.Join(keyDir, "test.key")
configContent := `logs:
- shortname: "test-log"
secret: "` + keyPath + `"`
@@ -188,10 +188,10 @@ func TestGenerateKeysCreateDirectory(t *testing.T) {
func TestGenerateKeysMultipleRuns(t *testing.T) {
tmpDir := t.TempDir()
key1Path := filepath.Join(tmpDir, "key1.key")
key2Path := filepath.Join(tmpDir, "key2.key")
configContent := `logs:
- shortname: "test-log-1"
secret: "` + key1Path + `"
@@ -244,7 +244,7 @@ func TestGenerateKeysMultipleRuns(t *testing.T) {
func TestECKeyGeneration(t *testing.T) {
tmpDir := t.TempDir()
keyPath := filepath.Join(tmpDir, "test.key")
configContent := `logs:
- shortname: "test-log"
secret: "` + keyPath + `"`
@@ -293,4 +293,4 @@ func TestECKeyGeneration(t *testing.T) {
if err != nil {
t.Errorf("Failed to marshal public key: %v", err)
}
}
}