Skip to content

Commit

Permalink
Apply goconst
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Mar 27, 2024
1 parent 9599e59 commit 290b774
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ linters:
- gocritic
- gocognit
- dupl
- goconst
- golint

issues:
max-ame-issues: 50
Expand Down
4 changes: 2 additions & 2 deletions decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestDecodeFile(t *testing.T) {

// Test password matching
pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword()
if pw != "Password" {
if pw != password {
t.Fatalf(
"Failed to decode password: should be 'Password' not '%s'",
pw,
Expand All @@ -161,7 +161,7 @@ func TestDecodeFile(t *testing.T) {

// Test secondary password matching
pw = db.Content.Root.Groups[0].Groups[0].Entries[1].GetPassword()
if pw != "AnotherPassword" {
if pw != anotherPassword {
t.Fatalf(
"Failed to decode password: should be 'AnotherPassword' not '%s'",
pw,
Expand Down
26 changes: 7 additions & 19 deletions encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ func TestEncodeFile31(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon,
},
}

Expand Down Expand Up @@ -99,7 +96,7 @@ func TestEncodeFile31(t *testing.T) {

// Test password matching
pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword()
if pw != "Password" {
if pw != password {
t.Fatalf(
"Failed to decode password: should be 'Password' not '%s'",
pw,
Expand Down Expand Up @@ -135,10 +132,7 @@ func TestEncodeFile31(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon,
},
) {
t.Fatal("Failed to properly store a custom icon in the Meta block")
Expand Down Expand Up @@ -192,10 +186,7 @@ func TestEncodeFile4(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon,
},
}

Expand Down Expand Up @@ -235,7 +226,7 @@ func TestEncodeFile4(t *testing.T) {

// Test password matching
pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword()
if pw != "Password" {
if pw != password {
t.Fatalf(
"Failed to decode password: should be 'Password' not '%s'",
pw,
Expand Down Expand Up @@ -270,10 +261,7 @@ func TestEncodeFile4(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon,
},
) {
t.Fatal("Failed to properly store a custom icon in the Meta block")
Expand Down Expand Up @@ -350,7 +338,7 @@ func TestEncodeFile4_NoCompression(t *testing.T) {

// Test password matching
pw := db.Content.Root.Groups[0].Groups[0].Entries[0].GetPassword()
if pw != "Password" {
if pw != password {
t.Fatalf(
"Failed to decode password: should be 'Password' not '%s'",
pw,
Expand Down
20 changes: 4 additions & 16 deletions meta_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func TestNewMetaData(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon,
},
{
UUID{
Expand All @@ -64,10 +61,7 @@ func TestNewMetaData(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon,
},
}
},
Expand All @@ -86,10 +80,7 @@ func TestNewMetaData(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon2,
},
{
UUID{
Expand All @@ -98,10 +89,7 @@ func TestNewMetaData(t *testing.T) {
0xed, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd,
},
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC",
encodedIcon2,
},
},
},
Expand Down
15 changes: 15 additions & 0 deletions shared_for_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gokeepasslib

const (
password = "Password"
anotherPassword = "AnotherPassword"

encodedIcon = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC"
encodedIcon2 = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IA" +
"rs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAA" +
"gOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACZJREFUOE9jbGBo+M9ACQAZ" +
"QAlmoEQz2PWjBoyGwWg6AGdCivMCAKxN4SAQ+6S+AAAAAElFTkSuQmCC"
)

0 comments on commit 290b774

Please sign in to comment.