mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Model refactor (#3915)
* Add mockery config file * Move basic file/folder structs to models * Fix hack due to import loop * Move file interfaces to models * Move folder interfaces to models * Move scene interfaces to models * Move scene marker interfaces to models * Move image interfaces to models * Move gallery interfaces to models * Move gallery chapter interfaces to models * Move studio interfaces to models * Move movie interfaces to models * Move performer interfaces to models * Move tag interfaces to models * Move autotag interfaces to models * Regenerate mocks
This commit is contained in:
157
pkg/models/fingerprint_test.go
Normal file
157
pkg/models/fingerprint_test.go
Normal file
@@ -0,0 +1,157 @@
|
||||
package models
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFingerprints_Equals(t *testing.T) {
|
||||
var (
|
||||
value1 = 1
|
||||
value2 = "2"
|
||||
value3 = 1.23
|
||||
|
||||
fingerprint1 = Fingerprint{
|
||||
Type: FingerprintTypeMD5,
|
||||
Fingerprint: value1,
|
||||
}
|
||||
fingerprint2 = Fingerprint{
|
||||
Type: FingerprintTypeOshash,
|
||||
Fingerprint: value2,
|
||||
}
|
||||
fingerprint3 = Fingerprint{
|
||||
Type: FingerprintTypePhash,
|
||||
Fingerprint: value3,
|
||||
}
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
f Fingerprints
|
||||
other Fingerprints
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
"identical",
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"different order",
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint2,
|
||||
fingerprint1,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"different length",
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"different",
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint3,
|
||||
},
|
||||
false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.f.Equals(tt.other); got != tt.want {
|
||||
t.Errorf("Fingerprints.Equals() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFingerprints_ContentsChanged(t *testing.T) {
|
||||
var (
|
||||
value1 = 1
|
||||
value2 = "2"
|
||||
value3 = 1.23
|
||||
|
||||
fingerprint1 = Fingerprint{
|
||||
Type: FingerprintTypeMD5,
|
||||
Fingerprint: value1,
|
||||
}
|
||||
fingerprint2 = Fingerprint{
|
||||
Type: FingerprintTypeOshash,
|
||||
Fingerprint: value2,
|
||||
}
|
||||
fingerprint3 = Fingerprint{
|
||||
Type: FingerprintTypeMD5,
|
||||
Fingerprint: value3,
|
||||
}
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
f Fingerprints
|
||||
other Fingerprints
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
"identical",
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"has new",
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"has different value",
|
||||
Fingerprints{
|
||||
fingerprint3,
|
||||
fingerprint2,
|
||||
},
|
||||
Fingerprints{
|
||||
fingerprint1,
|
||||
fingerprint2,
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.f.ContentsChanged(tt.other); got != tt.want {
|
||||
t.Errorf("Fingerprints.ContentsChanged() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user