Use images from example data to prevent initializing testdata in colors test to make test faster
This commit is contained in:
parent
f9c18446bf
commit
31896eda13
2 changed files with 21 additions and 25 deletions
2
assets/resources/database/.gitignore
vendored
2
assets/resources/database/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -94,70 +94,68 @@ func TestMediaFile_Colors_Testdata(t *testing.T) {
|
|||
func TestMediaFile_Colors(t *testing.T) {
|
||||
conf := config.TestConfig()
|
||||
|
||||
conf.InitializeTestData(t)
|
||||
|
||||
t.Run("dog.jpg", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ImportPath() + "/dog.jpg"); err == nil {
|
||||
t.Run("cat_brown.jpg", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/cat_brown.jpg"); err == nil {
|
||||
p, err := mediaFile.Colors(conf.ThumbnailsPath())
|
||||
|
||||
t.Log(p, err)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 11, p.Chroma.Int())
|
||||
assert.Equal(t, 13, p.Chroma.Int())
|
||||
assert.IsType(t, IndexedColors{}, p.Colors)
|
||||
assert.Equal(t, "brown", p.MainColor.Name())
|
||||
assert.Equal(t, IndexedColors{0x1, 0x3, 0x1, 0x2, 0xe, 0x0, 0x2, 0x2, 0x0}, p.Colors)
|
||||
assert.Equal(t, LightMap{0x4, 0xf, 0x8, 0xc, 0x4, 0x2, 0x4, 0x3, 0x0}, p.Luminance)
|
||||
assert.Equal(t, "gold", p.MainColor.Name())
|
||||
assert.Equal(t, IndexedColors{0x9, 0x5, 0x1, 0x2, 0x2, 0x1, 0x0, 0x6, 0x2}, p.Colors)
|
||||
assert.Equal(t, LightMap{0x4, 0x5, 0xb, 0x4, 0x7, 0x3, 0x2, 0x5, 0x7}, p.Luminance)
|
||||
} else {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("ape.jpeg", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ImportPath() + "/ape.jpeg"); err == nil {
|
||||
t.Run("fern_green.jpg", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/fern_green.jpg"); err == nil {
|
||||
p, err := mediaFile.Colors(conf.ThumbnailsPath())
|
||||
|
||||
t.Log(p, err)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 19, p.Chroma.Int())
|
||||
assert.Equal(t, 51, p.Chroma.Int())
|
||||
assert.IsType(t, IndexedColors{}, p.Colors)
|
||||
assert.Equal(t, "green", p.MainColor.Name())
|
||||
assert.Equal(t, IndexedColors{0x9, 0x9, 0x9, 0x8, 0x9, 0x2, 0x9, 0x2, 0x9}, p.Colors)
|
||||
assert.Equal(t, LightMap{0x6, 0xb, 0x9, 0x7, 0x9, 0x6, 0x8, 0xa, 0xe}, p.Luminance)
|
||||
assert.Equal(t, "lime", p.MainColor.Name())
|
||||
assert.Equal(t, IndexedColors{0xa, 0x9, 0xa, 0x9, 0xa, 0xa, 0x9, 0x9, 0x9}, p.Colors)
|
||||
assert.Equal(t, LightMap{0xb, 0x4, 0xa, 0x6, 0x9, 0x8, 0x2, 0x3, 0x4}, p.Luminance)
|
||||
} else {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("iphone/IMG_6788.JPG", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err == nil {
|
||||
t.Run("IMG_4120.JPG", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/IMG_4120.JPG"); err == nil {
|
||||
p, err := mediaFile.Colors(conf.ThumbnailsPath())
|
||||
|
||||
t.Log(p, err)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 17, p.Chroma.Int())
|
||||
assert.Equal(t, 7, p.Chroma.Int())
|
||||
assert.IsType(t, IndexedColors{}, p.Colors)
|
||||
assert.Equal(t, "blue", p.MainColor.Name())
|
||||
assert.Equal(t, IndexedColors{0x6, 0x6, 0x9, 0x1, 0x0, 0x2, 0x1, 0x1, 0x6}, p.Colors)
|
||||
assert.Equal(t, IndexedColors{0x2, 0x6, 0x6, 0x2, 0x2, 0x9, 0x2, 0x0, 0x0}, p.Colors)
|
||||
} else {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("raw/20140717_154212_1EC48F8489.jpg", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"); err == nil {
|
||||
t.Run("leaves_gold.jpg", func(t *testing.T) {
|
||||
if mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/leaves_gold.jpg"); err == nil {
|
||||
p, err := mediaFile.Colors(conf.ThumbnailsPath())
|
||||
|
||||
t.Log(p, err)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 14, p.Chroma.Int())
|
||||
assert.Equal(t, 16, p.Chroma.Int())
|
||||
assert.IsType(t, IndexedColors{}, p.Colors)
|
||||
assert.Equal(t, "green", p.MainColor.Name())
|
||||
assert.Equal(t, "gold", p.MainColor.Name())
|
||||
|
||||
assert.Equal(t, IndexedColors{0x3, 0x3, 0x6, 0x1, 0x2, 0x2, 0x9, 0x9, 0x9}, p.Colors)
|
||||
assert.Equal(t, IndexedColors{0x0, 0x0, 0x1, 0x5, 0x5, 0x0, 0x1, 0x5, 0x0}, p.Colors)
|
||||
} else {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue