Test: Use PascalCase names for all Go subtests in /internal

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-10-02 14:50:02 +02:00
parent c68493da8a
commit 94b6631b3d
239 changed files with 1909 additions and 1909 deletions

View File

@@ -22,13 +22,13 @@ func TestLabelRule_Find(t *testing.T) {
},
}
t.Run("existing rule", func(t *testing.T) {
t.Run("ExistingRule", func(t *testing.T) {
result, ok := rules.Find("cat")
assert.True(t, ok)
assert.Equal(t, -2, result.Priority)
assert.Equal(t, float32(1), result.Threshold)
})
t.Run("not existing rule", func(t *testing.T) {
t.Run("NotExistingRule", func(t *testing.T) {
result, ok := rules.Find("fish")
assert.False(t, ok)
t.Log(result)

View File

@@ -13,21 +13,21 @@ func TestLabel_NewLocationLabel(t *testing.T) {
assert.Equal(t, 23, LocLabel.Uncertainty)
assert.Equal(t, "locationtest", LocLabel.Name)
t.Run("locationtest / slash", func(t *testing.T) {
t.Run("LocationtestSlash", func(t *testing.T) {
LocLabel := LocationLabel("locationtest / slash", 24)
t.Log(LocLabel)
assert.Equal(t, "location", LocLabel.Source)
assert.Equal(t, 24, LocLabel.Uncertainty)
assert.Equal(t, "locationtest", LocLabel.Name)
})
t.Run("locationtest - minus", func(t *testing.T) {
t.Run("LocationtestMinus", func(t *testing.T) {
LocLabel := LocationLabel("locationtest - minus", 80)
t.Log(LocLabel)
assert.Equal(t, "location", LocLabel.Source)
assert.Equal(t, 80, LocLabel.Uncertainty)
assert.Equal(t, "locationtest", LocLabel.Name)
})
t.Run("label as name", func(t *testing.T) {
t.Run("LabelAsName", func(t *testing.T) {
LocLabel := LocationLabel("barracouta", 80)
t.Log(LocLabel)
assert.Equal(t, "location", LocLabel.Source)
@@ -39,11 +39,11 @@ func TestLabel_NewLocationLabel(t *testing.T) {
}
func TestLabel_Title(t *testing.T) {
t.Run("locationtest123", func(t *testing.T) {
t.Run("Locationtest123", func(t *testing.T) {
LocLabel := LocationLabel("locationtest123", 23)
assert.Equal(t, "Locationtest123", LocLabel.Title())
})
t.Run("Berlin/Neukölln", func(t *testing.T) {
t.Run("BerlinNeukLln", func(t *testing.T) {
LocLabel := LocationLabel("berlin/neukölln_hasenheide", 23)
assert.Equal(t, "Berlin / Neukölln Hasenheide", LocLabel.Title())
})

View File

@@ -12,7 +12,7 @@ func TestLabel_AppendLabel(t *testing.T) {
dog := Label{Name: "dog", Source: "location", Uncertainty: 80, Priority: 5}
labels := Labels{cat, dog}
t.Run("labelWithName", func(t *testing.T) {
t.Run("LabelWithName", func(t *testing.T) {
assert.Equal(t, 2, labels.Len())
cow := Label{Name: "cow", Source: "location", Uncertainty: 80, Priority: 5}
labelsNew := labels.AppendLabel(cow)
@@ -21,7 +21,7 @@ func TestLabel_AppendLabel(t *testing.T) {
assert.Equal(t, "cat", labelsNew[0].Name)
assert.Equal(t, "cow", labelsNew[2].Name)
})
t.Run("labelWithoutName", func(t *testing.T) {
t.Run("LabelWithoutName", func(t *testing.T) {
assert.Equal(t, 2, labels.Len())
cow := Label{Name: "", Source: "location", Uncertainty: 80, Priority: 5}
labelsNew := labels.AppendLabel(cow)
@@ -31,40 +31,40 @@ func TestLabel_AppendLabel(t *testing.T) {
}
func TestLabels_Title(t *testing.T) {
t.Run("first", func(t *testing.T) {
t.Run("First", func(t *testing.T) {
cat := Label{Name: "cat", Source: "location", Uncertainty: 59, Priority: 5}
dog := Label{Name: "dog", Source: "location", Uncertainty: 10, Priority: 4}
labels := Labels{cat, dog}
assert.Equal(t, "cat", labels.Title("fallback"))
})
t.Run("second", func(t *testing.T) {
t.Run("Second", func(t *testing.T) {
cat := Label{Name: "cat", Source: "location", Uncertainty: 61, Priority: 5}
dog := Label{Name: "dog", Source: "location", Uncertainty: 10, Priority: 4}
labels := Labels{cat, dog}
assert.Equal(t, "dog", labels.Title("fallback"))
})
t.Run("fallback", func(t *testing.T) {
t.Run("Fallback", func(t *testing.T) {
cat := Label{Name: "cat", Source: "location", Uncertainty: 80, Priority: 5}
dog := Label{Name: "dog", Source: "location", Uncertainty: 80, Priority: 4}
labels := Labels{cat, dog}
assert.Equal(t, "fallback", labels.Title("fallback"))
})
t.Run("empty labels", func(t *testing.T) {
t.Run("EmptyLabels", func(t *testing.T) {
labels := Labels{}
assert.Equal(t, "", labels.Title(""))
})
t.Run("label priority < 0", func(t *testing.T) {
t.Run("LabelPriorityLessThanZero", func(t *testing.T) {
cat := Label{Name: "cat", Source: "location", Uncertainty: 59, Priority: -1}
dog := Label{Name: "dog", Source: "location", Uncertainty: 10, Priority: -1}
labels := Labels{cat, dog}
assert.Equal(t, "fallback", labels.Title("fallback"))
})
t.Run("label priority = 0", func(t *testing.T) {
t.Run("LabelPriorityEqualZero", func(t *testing.T) {
cat := Label{Name: "cat", Source: "location", Uncertainty: 59, Priority: 0}
dog := Label{Name: "dog", Source: "location", Uncertainty: 62, Priority: 0}
labels := Labels{cat, dog}
@@ -79,7 +79,7 @@ func TestLabels_Keywords(t *testing.T) {
bird := Label{Name: "bird", Source: "image", Uncertainty: 100, Priority: 2}
labels := Labels{cat, dog, bird}
t.Run("labelWithName", func(t *testing.T) {
t.Run("LabelWithName", func(t *testing.T) {
result := labels.Keywords()
t.Log(result)
assert.Equal(t, "cat", result[0])

View File

@@ -38,7 +38,7 @@ func TestModel_CenterCrop(t *testing.T) {
model.meta.Input.ResizeOperation = tensorflow.CenterCrop
t.Run("nasnet padding", func(t *testing.T) {
t.Run("NasnetPadding", func(t *testing.T) {
runBasicLabelsTest(t, model, 6)
})
}
@@ -51,7 +51,7 @@ func TestModel_Padding(t *testing.T) {
model.meta.Input.ResizeOperation = tensorflow.Padding
t.Run("nasnet padding", func(t *testing.T) {
t.Run("NasnetPadding", func(t *testing.T) {
runBasicLabelsTest(t, model, 6)
})
}
@@ -64,7 +64,7 @@ func TestModel_ResizeBreakAspectRatio(t *testing.T) {
model.meta.Input.ResizeOperation = tensorflow.ResizeBreakAspectRatio
t.Run("nasnet break aspect ratio", func(t *testing.T) {
t.Run("NasnetBreakAspectRatio", func(t *testing.T) {
runBasicLabelsTest(t, model, 4)
})
}
@@ -85,7 +85,7 @@ func runBasicLabelsTest(t *testing.T, model *Model, expectedUncertainty int) {
}
func TestModel_LabelsFromFile(t *testing.T) {
t.Run("chameleon_lime.jpg", func(t *testing.T) {
t.Run("ChameleonLimeJpg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
result, err := tensorFlow.File(examplesPath+"/chameleon_lime.jpg", 10)
@@ -101,7 +101,7 @@ func TestModel_LabelsFromFile(t *testing.T) {
assert.Equal(t, 7, result[0].Uncertainty)
}
})
t.Run("cat_224.jpeg", func(t *testing.T) {
t.Run("CatNum224Jpeg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
result, err := tensorFlow.File(examplesPath+"/cat_224.jpeg", 10)
@@ -116,7 +116,7 @@ func TestModel_LabelsFromFile(t *testing.T) {
assert.Equal(t, 59, result[0].Uncertainty)
}
})
t.Run("cat_720.jpeg", func(t *testing.T) {
t.Run("CatNum720Jpeg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
result, err := tensorFlow.File(examplesPath+"/cat_720.jpeg", 10)
@@ -132,7 +132,7 @@ func TestModel_LabelsFromFile(t *testing.T) {
assert.Equal(t, 60, result[0].Uncertainty)
}
})
t.Run("green.jpg", func(t *testing.T) {
t.Run("GreenJpg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
result, err := tensorFlow.File(examplesPath+"/green.jpg", 10)
@@ -178,7 +178,7 @@ func TestModel_Run(t *testing.T) {
t.Skip("skipping test in short mode.")
}
t.Run("chameleon_lime.jpg", func(t *testing.T) {
t.Run("ChameleonLimeJpg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
if imageBuffer, err := os.ReadFile(examplesPath + "/chameleon_lime.jpg"); err != nil {
@@ -203,7 +203,7 @@ func TestModel_Run(t *testing.T) {
}
}
})
t.Run("dog_orange.jpg", func(t *testing.T) {
t.Run("DogOrangeJpg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
if imageBuffer, err := os.ReadFile(examplesPath + "/dog_orange.jpg"); err != nil {
@@ -228,7 +228,7 @@ func TestModel_Run(t *testing.T) {
}
}
})
t.Run("Random.docx", func(t *testing.T) {
t.Run("RandomDocx", func(t *testing.T) {
tensorFlow := NewModelTest(t)
if imageBuffer, err := os.ReadFile(examplesPath + "/Random.docx"); err != nil {
@@ -239,7 +239,7 @@ func TestModel_Run(t *testing.T) {
assert.Error(t, err)
}
})
t.Run("6720px_white.jpg", func(t *testing.T) {
t.Run("Num6720PxWhiteJpg", func(t *testing.T) {
tensorFlow := NewModelTest(t)
if imageBuffer, err := os.ReadFile(examplesPath + "/6720px_white.jpg"); err != nil {

View File

@@ -12,22 +12,22 @@ var area3 = NewArea("face3", 900, 500, 25)
var area4 = NewArea("face4", 110, 110, 60)
func TestArea_TopLeft(t *testing.T) {
t.Run("area1", func(t *testing.T) {
t.Run("Area1", func(t *testing.T) {
x, y := area1.TopLeft()
assert.Equal(t, 300, x)
assert.Equal(t, 150, y)
})
t.Run("area2", func(t *testing.T) {
t.Run("Area2", func(t *testing.T) {
x, y := area2.TopLeft()
assert.Equal(t, 75, x)
assert.Equal(t, 75, y)
})
t.Run("area3", func(t *testing.T) {
t.Run("Area3", func(t *testing.T) {
x, y := area3.TopLeft()
assert.Equal(t, 888, x)
assert.Equal(t, 488, y)
})
t.Run("area4", func(t *testing.T) {
t.Run("Area4", func(t *testing.T) {
x, y := area4.TopLeft()
assert.Equal(t, 80, x)
assert.Equal(t, 80, y)

View File

@@ -29,13 +29,13 @@ func TestEmbeddings_Count(t *testing.T) {
one := Embeddings{e1}
two := Embeddings{e1, e2}
t.Run("0", func(t *testing.T) {
t.Run("Zero", func(t *testing.T) {
assert.Equal(t, 0, Embeddings{}.Count())
})
t.Run("1", func(t *testing.T) {
t.Run("One", func(t *testing.T) {
assert.Equal(t, 1, one.Count())
})
t.Run("2", func(t *testing.T) {
t.Run("Two", func(t *testing.T) {
assert.Equal(t, 2, two.Count())
})
}
@@ -81,7 +81,7 @@ func TestEmbeddings_First(t *testing.T) {
}
func TestEmbeddingsMidpoint(t *testing.T) {
t.Run("2 embeddings, 1 dimension", func(t *testing.T) {
t.Run("TwoEmbeddingsOneDimension", func(t *testing.T) {
e := Embeddings{Embedding{1}, Embedding{3}}
result, r, c := EmbeddingsMidpoint(e)
@@ -90,7 +90,7 @@ func TestEmbeddingsMidpoint(t *testing.T) {
assert.Equal(t, 1.01, r)
assert.Equal(t, 2, c)
})
t.Run("3 embeddings, 1 dimension", func(t *testing.T) {
t.Run("ThreeEmbeddingsOneDimension", func(t *testing.T) {
e := Embeddings{Embedding{1}, Embedding{3}, Embedding{4}}
result, r, c := EmbeddingsMidpoint(e)
@@ -99,7 +99,7 @@ func TestEmbeddingsMidpoint(t *testing.T) {
assert.Equal(t, 1.6766666666666665, r)
assert.Equal(t, 3, c)
})
t.Run("4 embeddings, 1 dimension", func(t *testing.T) {
t.Run("FourEmbeddingsOneDimension", func(t *testing.T) {
e := Embeddings{Embedding{1}, Embedding{3}, Embedding{4}, Embedding{8}}
result, r, c := EmbeddingsMidpoint(e)
@@ -108,7 +108,7 @@ func TestEmbeddingsMidpoint(t *testing.T) {
assert.Equal(t, 4.01, r)
assert.Equal(t, 4, c)
})
t.Run("empty embedding", func(t *testing.T) {
t.Run("EmptyEmbedding", func(t *testing.T) {
e := Embeddings{}
result, r, c := EmbeddingsMidpoint(e)
@@ -117,7 +117,7 @@ func TestEmbeddingsMidpoint(t *testing.T) {
assert.Equal(t, float64(0), r)
assert.Equal(t, 0, c)
})
t.Run("embedding with different length", func(t *testing.T) {
t.Run("EmbeddingWithDifferentLength", func(t *testing.T) {
e := Embeddings{Embedding{1}, Embedding{3, 5}}
result, r, c := EmbeddingsMidpoint(e)
@@ -126,7 +126,7 @@ func TestEmbeddingsMidpoint(t *testing.T) {
assert.Equal(t, 1.01, r)
assert.Equal(t, 2, c)
})
t.Run("vectors", func(t *testing.T) {
t.Run("Vectors", func(t *testing.T) {
e := Embeddings{Embedding{1, 0, 0, 0}, Embedding{0, 1, 0, 0}, Embedding{0, 0, 1, 0}, Embedding{0, 0, 0, 1}}
result, radius, count := EmbeddingsMidpoint(e)

View File

@@ -7,7 +7,7 @@ import (
)
func TestFace_Size(t *testing.T) {
t.Run("8", func(t *testing.T) {
t.Run("Eight", func(t *testing.T) {
f := Face{
Rows: 8,
Cols: 1,
@@ -27,7 +27,7 @@ func TestFace_Size(t *testing.T) {
}
func TestFace_Dim(t *testing.T) {
t.Run("3", func(t *testing.T) {
t.Run("Three", func(t *testing.T) {
f := Face{
Rows: 8,
Cols: 3,
@@ -44,7 +44,7 @@ func TestFace_Dim(t *testing.T) {
}
assert.Equal(t, float32(3), f.Dim())
})
t.Run("1", func(t *testing.T) {
t.Run("One", func(t *testing.T) {
f := Face{
Rows: 8,
Cols: 0,
@@ -64,7 +64,7 @@ func TestFace_Dim(t *testing.T) {
}
func TestFace_EmbeddingsJSON(t *testing.T) {
t.Run("no result", func(t *testing.T) {
t.Run("NoResult", func(t *testing.T) {
f := Face{
Rows: 8,
Cols: 1,

View File

@@ -7,19 +7,19 @@ import (
)
func TestFaces_Uncertainty(t *testing.T) {
t.Run("maxScore = 310", func(t *testing.T) {
t.Run("MaxScoreEqualNum310", func(t *testing.T) {
f := Faces{Face{Score: 310}, Face{Score: 210}}
assert.Equal(t, 1, f.Uncertainty())
})
t.Run("maxScore = 210", func(t *testing.T) {
t.Run("MaxScoreEqualNum210", func(t *testing.T) {
f := Faces{Face{Score: 210}, Face{Score: 210}}
assert.Equal(t, 5, f.Uncertainty())
})
t.Run("maxScore = 66", func(t *testing.T) {
t.Run("MaxScoreEqualNum66", func(t *testing.T) {
f := Faces{Face{Score: 66}, Face{Score: 66}}
assert.Equal(t, 20, f.Uncertainty())
})
t.Run("maxScore = 10", func(t *testing.T) {
t.Run("MaxScoreEqualTen", func(t *testing.T) {
f := Faces{Face{Score: 10}, Face{Score: 10}}
assert.Equal(t, 50, f.Uncertainty())
})

View File

@@ -25,7 +25,7 @@ func TestCanonicalLabelForUnknown(t *testing.T) {
}
func TestNormalizeLabelResult(t *testing.T) {
t.Run("canonical", func(t *testing.T) {
t.Run("Canonical", func(t *testing.T) {
label := LabelResult{Name: "sea lion", Confidence: 0.8, Topicality: 0.7}
normalizeLabelResult(&label)
@@ -41,7 +41,7 @@ func TestNormalizeLabelResult(t *testing.T) {
t.Fatalf("expected categories to be set")
}
})
t.Run("fallback", func(t *testing.T) {
t.Run("Fallback", func(t *testing.T) {
label := LabelResult{Name: "kittens", Confidence: 0.2, Topicality: 0.25}
normalizeLabelResult(&label)
@@ -53,7 +53,7 @@ func TestNormalizeLabelResult(t *testing.T) {
t.Fatalf("expected priority to be derived from topicality")
}
})
t.Run("ignored_threshold", func(t *testing.T) {
t.Run("IgnoredThreshold", func(t *testing.T) {
label := LabelResult{Name: "background", Topicality: 0.9}
normalizeLabelResult(&label)
@@ -61,7 +61,7 @@ func TestNormalizeLabelResult(t *testing.T) {
t.Fatalf("expected background to be ignored, got %q", label.Name)
}
})
t.Run("global_threshold", func(t *testing.T) {
t.Run("GlobalThreshold", func(t *testing.T) {
prev := Config.Thresholds.Confidence
Config.Thresholds.Confidence = 90
defer func() { Config.Thresholds.Confidence = prev }()
@@ -73,7 +73,7 @@ func TestNormalizeLabelResult(t *testing.T) {
t.Fatalf("expected label to be dropped due to global threshold, got %q", label.Name)
}
})
t.Run("apostrophe", func(t *testing.T) {
t.Run("Apostrophe", func(t *testing.T) {
label := LabelResult{Name: "McDonald's", Confidence: 0.8, Topicality: 0.6}
normalizeLabelResult(&label)

View File

@@ -8,7 +8,7 @@ import (
)
func TestNewResponse(t *testing.T) {
t.Run("404", func(t *testing.T) {
t.Run("Num404", func(t *testing.T) {
r := NewResponse(404, errors.New("not found"), "details")
assert.Equal(t, 404, r.Code)
assert.Equal(t, "details", r.Details)

View File

@@ -121,7 +121,7 @@ func TestBatchAlbumsDelete(t *testing.T) {
assert.Equal(t, i18n.Msg(i18n.ErrAlbumNotFound), val3.String())
assert.Equal(t, http.StatusNotFound, r3.Code)
})
t.Run("no albums selected", func(t *testing.T) {
t.Run("NoAlbumsSelected", func(t *testing.T) {
app, router, _ := NewApiTest()
BatchAlbumsDelete(router)
r := PerformRequestWithBody(app, "POST", "/api/v1/batch/albums/delete", `{"albums": []}`)
@@ -206,7 +206,7 @@ func TestBatchLabelsDelete(t *testing.T) {
val3 := gjson.Get(r3.Body.String(), `#(Name=="BatchDelete").Slug`)
assert.Equal(t, val3.String(), "")
})
t.Run("no labels selected", func(t *testing.T) {
t.Run("NoLabelsSelected", func(t *testing.T) {
app, router, _ := NewApiTest()
BatchLabelsDelete(router)
r := PerformRequestWithBody(app, "POST", "/api/v1/batch/labels/delete", `{"labels": []}`)

View File

@@ -60,7 +60,7 @@ func TestClusterNodesRegister(t *testing.T) {
r := PerformRequestWithBody(app, http.MethodPost, "/api/v1/cluster/nodes/register", `{"nodeName":"pp-node-01"}`)
assert.Equal(t, http.StatusUnauthorized, r.Code)
})
t.Run("CreateNode_SucceedsWithProvisioner", func(t *testing.T) {
t.Run("CreateNodeSucceedsWithProvisioner", func(t *testing.T) {
app, router, conf := NewApiTest()
conf.Options().NodeRole = cluster.RolePortal
conf.Options().JoinToken = cluster.ExampleJoinToken

View File

@@ -17,13 +17,13 @@ func TestAlbumCover(t *testing.T) {
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("album contains no photos (because is not existing)", func(t *testing.T) {
t.Run("AlbumContainsNoPhotosBecauseIsNotExisting", func(t *testing.T) {
app, router, conf := NewApiTest()
AlbumCover(router)
r := PerformRequest(app, "GET", "/api/v1/albums/987-986435/t/"+conf.PreviewToken()+"/tile_500")
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("album: could not find original", func(t *testing.T) {
t.Run("AlbumCouldNotFindOriginal", func(t *testing.T) {
app, router, conf := NewApiTest()
AlbumCover(router)
r := PerformRequest(app, "GET", "/api/v1/albums/as6sg6bxpogaaba9/t/"+conf.PreviewToken()+"/tile_500")
@@ -46,14 +46,14 @@ func TestLabelCover(t *testing.T) {
r := PerformRequest(app, "GET", "/api/v1/labels/ls6sg6b1wowuy3c2/t/"+conf.PreviewToken()+"/xxx")
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("invalid label", func(t *testing.T) {
t.Run("InvalidLabel", func(t *testing.T) {
app, router, conf := NewApiTest()
LabelCover(router)
r := PerformRequest(app, "GET", "/api/v1/labels/xxx/t/"+conf.PreviewToken()+"/tile_500")
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("could not find original", func(t *testing.T) {
t.Run("CouldNotFindOriginal", func(t *testing.T) {
app, router, conf := NewApiTest()
LabelCover(router)
//r := PerformRequest(app, "GET", "/api/v1/labels/ls6sg6b1wowuy3c3/t/"+conf.PreviewToken()+"/tile_500")

View File

@@ -8,7 +8,7 @@ import (
)
func TestDeleteFile(t *testing.T) {
t.Run("delete not existing file", func(t *testing.T) {
t.Run("DeleteNotExistingFile", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteFile(router)
@@ -16,7 +16,7 @@ func TestDeleteFile(t *testing.T) {
r := PerformRequest(app, "DELETE", "/api/v1/photos/5678/files/23456hbg")
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("delete primary file", func(t *testing.T) {
t.Run("DeletePrimaryFile", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteFile(router)
@@ -24,7 +24,7 @@ func TestDeleteFile(t *testing.T) {
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/files/fs6sg6bw45bnlqdw")
assert.Equal(t, http.StatusInternalServerError, r.Code)
})
t.Run("try to delete file", func(t *testing.T) {
t.Run("TryToDeleteFile", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteFile(router)

View File

@@ -10,7 +10,7 @@ import (
)
func TestGetFile(t *testing.T) {
t.Run("search for existing file", func(t *testing.T) {
t.Run("SearchForExistingFile", func(t *testing.T) {
app, router, _ := NewApiTest()
GetFile(router)
r := PerformRequest(app, "GET", "/api/v1/files/2cad9168fa6acc5c5c2965ddf6ec465ca42fd818")
@@ -19,7 +19,7 @@ func TestGetFile(t *testing.T) {
val := gjson.Get(r.Body.String(), "Name")
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", val.String())
})
t.Run("search for not existing file", func(t *testing.T) {
t.Run("SearchForNotExistingFile", func(t *testing.T) {
app, router, _ := NewApiTest()
GetFile(router)
r := PerformRequest(app, "GET", "/api/v1/files/111")

View File

@@ -12,7 +12,7 @@ import (
)
func TestGetFoldersOriginals(t *testing.T) {
t.Run("flat", func(t *testing.T) {
t.Run("Flat", func(t *testing.T) {
app, router, conf := NewApiTest()
_ = conf.CreateDirectories()
expected, err := fs.Dirs(conf.OriginalsPath(), false, true)
@@ -55,7 +55,7 @@ func TestGetFoldersOriginals(t *testing.T) {
assert.Equal(t, false, folder.FolderWatch)
}
})
t.Run("recursive", func(t *testing.T) {
t.Run("Recursive", func(t *testing.T) {
app, router, conf := NewApiTest()
_ = conf.CreateDirectories()
expected, err := fs.Dirs(conf.OriginalsPath(), true, true)
@@ -95,7 +95,7 @@ func TestGetFoldersOriginals(t *testing.T) {
}
func TestGetFoldersImport(t *testing.T) {
t.Run("flat", func(t *testing.T) {
t.Run("Flat", func(t *testing.T) {
app, router, conf := NewApiTest()
_ = conf.CreateDirectories()
expected, err := fs.Dirs(conf.ImportPath(), false, true)
@@ -139,7 +139,7 @@ func TestGetFoldersImport(t *testing.T) {
}
})
t.Run("recursive", func(t *testing.T) {
t.Run("Recursive", func(t *testing.T) {
app, router, conf := NewApiTest()
_ = conf.CreateDirectories()
expected, err := fs.Dirs(conf.ImportPath(), true, true)

View File

@@ -37,13 +37,13 @@ func TestUpdateLabel(t *testing.T) {
}
func TestLikeLabel(t *testing.T) {
t.Run("like not existing label", func(t *testing.T) {
t.Run("LikeNotExistingLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
LikeLabel(router)
r := PerformRequest(app, "POST", "/api/v1/labels/8775789/like")
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("like existing label", func(t *testing.T) {
t.Run("LikeExistingLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
// Register routes.
@@ -64,7 +64,7 @@ func TestLikeLabel(t *testing.T) {
val2 := gjson.Get(r3.Body.String(), `#(Slug=="like-label").Favorite`)
assert.Equal(t, "true", val2.String())
})
t.Run("like existing label with prio < 0", func(t *testing.T) {
t.Run("LikeExistingLabelWithPrioLessThanZero", func(t *testing.T) {
app, router, _ := NewApiTest()
LikeLabel(router)
r := PerformRequest(app, "POST", "/api/v1/labels/ls6sg6b1wowuy311/like")
@@ -75,7 +75,7 @@ func TestLikeLabel(t *testing.T) {
}
func TestDislikeLabel(t *testing.T) {
t.Run("dislike not existing label", func(t *testing.T) {
t.Run("DislikeNotExistingLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
DislikeLabel(router)
@@ -83,7 +83,7 @@ func TestDislikeLabel(t *testing.T) {
r := PerformRequest(app, "DELETE", "/api/v1/labels/5678/like")
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("dislike existing label", func(t *testing.T) {
t.Run("DislikeExistingLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
// Register routes.
@@ -102,7 +102,7 @@ func TestDislikeLabel(t *testing.T) {
val2 := gjson.Get(r3.Body.String(), `#(Slug=="landscape").Favorite`)
assert.Equal(t, "false", val2.String())
})
t.Run("dislike existing label with prio < 0", func(t *testing.T) {
t.Run("DislikeExistingLabelWithPrioLessThanZero", func(t *testing.T) {
app, router, _ := NewApiTest()
DislikeLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/labels/ls6sg6b1wowuy312/like")

View File

@@ -232,7 +232,7 @@ func TestUpdateAlbumLink(t *testing.T) {
assert.Equal(t, "8000", val2.String())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("bad request", func(t *testing.T) {
t.Run("BadRequest", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateAlbumLink(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/albums/as6sg6bxpogaaba7/links/"+uid, `{"Token": "newToken", "Expires": "vgft", "xxx": "xxx"}`)
@@ -256,7 +256,7 @@ func TestDeleteAlbumLink(t *testing.T) {
r2 := PerformRequest(app, "GET", "/api/v1/albums/as6sg6bxpogaaba7/links")
len := gjson.Get(r2.Body.String(), "#")
t.Run("successful deletion", func(t *testing.T) {
t.Run("SuccessfulDeletion", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteAlbumLink(router)
r := PerformRequest(app, "DELETE", "/api/v1/albums/as6sg6bxpogaaba7/links/"+uid)
@@ -295,7 +295,7 @@ func TestGetAlbumLinks(t *testing.T) {
/*
func TestCreatePhotoLink(t *testing.T) {
t.Run("create share link", func(t *testing.T) {
t.Run("CreateShareLink", func(t *testing.T) {
app, router, _ := NewApiTest()
var link entity.Link
@@ -317,7 +317,7 @@ func TestCreatePhotoLink(t *testing.T) {
assert.False(t, link.CanComment)
assert.True(t, link.CanEdit)
})
t.Run("photo not found", func(t *testing.T) {
t.Run("PhotoNotFound", func(t *testing.T) {
app, router, _ := NewApiTest()
CreatePhotoLink(router)
@@ -360,7 +360,7 @@ func TestUpdatePhotoLink(t *testing.T) {
assert.Equal(t, "8000", val2.String())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("bad request", func(t *testing.T) {
t.Run("BadRequest", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdatePhotoLink(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/photos/ps6sg6be2lvl0yh7/links/"+uid, `{"Token": "newToken", "Expires": "vgft", "xxx": "xxx"}`)
@@ -385,7 +385,7 @@ func TestDeletePhotoLink(t *testing.T) {
//r2 := PerformRequest(app, "GET", "/api/v1/photos/ps6sg6be2lvl0yh7/links")
//len := gjson.Get(r2.Body.String(), "#")
t.Run("successful deletion", func(t *testing.T) {
t.Run("SuccessfulDeletion", func(t *testing.T) {
app, router, _ := NewApiTest()
DeletePhotoLink(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/links/"+uid)
@@ -423,7 +423,7 @@ func TestGetPhotoLinks(t *testing.T) {
}
func TestCreateLabelLink(t *testing.T) {
t.Run("create share link", func(t *testing.T) {
t.Run("CreateShareLink", func(t *testing.T) {
app, router, _ := NewApiTest()
var link entity.Link
@@ -444,7 +444,7 @@ func TestCreateLabelLink(t *testing.T) {
assert.False(t, link.CanComment)
assert.True(t, link.CanEdit)
})
t.Run("label not found", func(t *testing.T) {
t.Run("LabelNotFound", func(t *testing.T) {
app, router, _ := NewApiTest()
CreateLabelLink(router)
resp := PerformRequestWithBody(app, "POST", "/api/v1/labels/xxx/links", `{"Password": "foobar", "Expires": 0, "CanEdit": true}`)
@@ -485,7 +485,7 @@ func TestUpdateLabelLink(t *testing.T) {
assert.Equal(t, "8000", val2.String())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("bad request", func(t *testing.T) {
t.Run("BadRequest", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateLabelLink(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/labels/ls6sg6b1wowuy3c2/links/"+uid, `{"Token": "newToken", "Expires": "vgft", "xxx": "xxx"}`)
@@ -509,7 +509,7 @@ func TestDeleteLabelLink(t *testing.T) {
//r2 := PerformRequest(app, "GET", "/api/v1/labels/ls6sg6b1wowuy3c2/links")
//len := gjson.Get(r2.Body.String(), "#")
t.Run("successful deletion", func(t *testing.T) {
t.Run("SuccessfulDeletion", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteLabelLink(router)
r := PerformRequest(app, "DELETE", "/api/v1/labels/ls6sg6b1wowuy3c2/links/"+uid)

View File

@@ -186,7 +186,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("bad request file and photouid not matching", func(t *testing.T) {
t.Run("BadRequestFileAndPhotouidNotMatching", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -195,7 +195,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("file not existing", func(t *testing.T) {
t.Run("FileNotExisting", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -204,7 +204,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("marker not existing", func(t *testing.T) {
t.Run("MarkerNotExisting", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -213,7 +213,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("empty photouid", func(t *testing.T) {
t.Run("EmptyPhotouid", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -222,7 +222,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("update cluster with existing subject", func(t *testing.T) {
t.Run("UpdateClusterWithExistingSubject", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -247,7 +247,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusOK, r.Code)
}
})
t.Run("update cluster with existing subject 2", func(t *testing.T) {
t.Run("UpdateClusterWithExistingSubjectTwo", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -272,7 +272,7 @@ func TestUpdateMarker(t *testing.T) {
assert.Equal(t, http.StatusOK, r.Code)
}
})
t.Run("invalid body", func(t *testing.T) {
t.Run("InvalidBody", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateMarker(router)
@@ -337,7 +337,7 @@ func TestClearMarkerSubject(t *testing.T) {
assert.Equal(t, http.StatusOK, resp.Code)
})
t.Run("non-primary file", func(t *testing.T) {
t.Run("NonPrimaryFile", func(t *testing.T) {
app, router, _ := NewApiTest()
ClearMarkerSubject(router)

View File

@@ -9,7 +9,7 @@ import (
)
func TestGetMetrics(t *testing.T) {
t.Run("expose count statistics", func(t *testing.T) {
t.Run("ExposeCountStatistics", func(t *testing.T) {
app, router, _ := NewApiTest()
GetMetrics(router)
@@ -29,7 +29,7 @@ func TestGetMetrics(t *testing.T) {
assert.Regexp(t, regexp.MustCompile(`photoprism_statistics_media_count{stat="folders"} \d+`), body)
assert.Regexp(t, regexp.MustCompile(`photoprism_statistics_media_count{stat="files"} \d+`), body)
})
t.Run("expose build information", func(t *testing.T) {
t.Run("ExposeBuildInformation", func(t *testing.T) {
app, router, _ := NewApiTest()
GetMetrics(router)
@@ -44,7 +44,7 @@ func TestGetMetrics(t *testing.T) {
assert.Regexp(t, regexp.MustCompile(`photoprism_build_info{edition=".+",goversion=".+",version=".+"} 1`), body)
})
t.Run("has prometheus exposition format as content type", func(t *testing.T) {
t.Run("HasPrometheusExpositionFormatAsContentType", func(t *testing.T) {
app, router, _ := NewApiTest()
GetMetrics(router)

View File

@@ -10,7 +10,7 @@ import (
)
func TestGetMomentsTime(t *testing.T) {
t.Run("get moments time", func(t *testing.T) {
t.Run("GetMomentsTime", func(t *testing.T) {
app, router, _ := NewApiTest()
GetMomentsTime(router)

View File

@@ -11,14 +11,14 @@ import (
)
func TestAddPhotoLabel(t *testing.T) {
t.Run("add new label", func(t *testing.T) {
t.Run("AddNewLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
AddPhotoLabel(router)
r := PerformRequestWithBody(app, "POST", "/api/v1/photos/ps6sg6be2lvl0yh8/label", `{"Name": "testAddLabel", "Uncertainty": 95, "Priority": 2}`)
assert.Equal(t, http.StatusOK, r.Code)
assert.Contains(t, r.Body.String(), "TestAddLabel")
})
t.Run("add existing label", func(t *testing.T) {
t.Run("AddExistingLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
AddPhotoLabel(router)
r := PerformRequestWithBody(app, "POST", "/api/v1/photos/ps6sg6be2lvl0yh8/label", `{"Name": "Flower", "Uncertainty": 10, "Priority": 2}`)
@@ -44,7 +44,7 @@ func TestAddPhotoLabel(t *testing.T) {
}
func TestRemovePhotoLabel(t *testing.T) {
t.Run("photo with label", func(t *testing.T) {
t.Run("PhotoWithLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
RemovePhotoLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/label/1000001")
@@ -54,7 +54,7 @@ func TestRemovePhotoLabel(t *testing.T) {
assert.Contains(t, r.Body.String(), "cake")
})
t.Run("remove manually added label", func(t *testing.T) {
t.Run("RemoveManuallyAddedLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
RemovePhotoLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/label/1000002")
@@ -62,7 +62,7 @@ func TestRemovePhotoLabel(t *testing.T) {
val := gjson.Get(r.Body.String(), "Labels")
assert.NotContains(t, val.String(), "cake")
})
t.Run("photo not found", func(t *testing.T) {
t.Run("PhotoNotFound", func(t *testing.T) {
app, router, _ := NewApiTest()
RemovePhotoLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/xxx/label/10000001")
@@ -70,13 +70,13 @@ func TestRemovePhotoLabel(t *testing.T) {
assert.Equal(t, i18n.Msg(i18n.ErrEntityNotFound), val.String())
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("label not existing", func(t *testing.T) {
t.Run("LabelNotExisting", func(t *testing.T) {
app, router, _ := NewApiTest()
RemovePhotoLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/label/xxx")
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("try to remove wrong label", func(t *testing.T) {
t.Run("TryToRemoveWrongLabel", func(t *testing.T) {
app, router, _ := NewApiTest()
RemovePhotoLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/label/1000000")
@@ -84,7 +84,7 @@ func TestRemovePhotoLabel(t *testing.T) {
assert.Equal(t, "Record not found", val.String())
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("not existing photo", func(t *testing.T) {
t.Run("NotExistingPhoto", func(t *testing.T) {
app, router, _ := NewApiTest()
RemovePhotoLabel(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/xx/label/")
@@ -101,7 +101,7 @@ func TestUpdatePhotoLabel(t *testing.T) {
val := gjson.Get(r.Body.String(), "Title")
assert.Contains(t, val.String(), "NewLabelName")
})
t.Run("photo not found", func(t *testing.T) {
t.Run("PhotoNotFound", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdatePhotoLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/photos/xxx/label/1000006", `{"Label": {"Name": "NewLabelName"}}`)
@@ -109,19 +109,19 @@ func TestUpdatePhotoLabel(t *testing.T) {
val := gjson.Get(r.Body.String(), "error")
assert.Equal(t, i18n.Msg(i18n.ErrEntityNotFound), val.String())
})
t.Run("label not existing", func(t *testing.T) {
t.Run("LabelNotExisting", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdatePhotoLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/photos/ps6sg6be2lvl0yh0/label/9000006", `{"Label": {"Name": "NewLabelName"}}`)
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("label not linked to photo", func(t *testing.T) {
t.Run("LabelNotLinkedToPhoto", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdatePhotoLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/photos/ps6sg6be2lvl0yh0/label/1000005", `{"Label": {"Name": "NewLabelName"}}`)
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("bad request", func(t *testing.T) {
t.Run("BadRequest", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdatePhotoLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/photos/ps6sg6be2lvl0yh0/label/1000006", `{"Label": {"Name": 123}}`)

View File

@@ -8,7 +8,7 @@ import (
)
func TestPhotoUnstack(t *testing.T) {
t.Run("unstack xmp sidecar file", func(t *testing.T) {
t.Run("UnstackXmpSidecarFile", func(t *testing.T) {
app, router, _ := NewApiTest()
PhotoUnstack(router)
r := PerformRequest(app, "POST", "/api/v1/photos/ps6sg6be2lvl0yh7/files/fs6sg6bw45bnlqdw/unstack")
@@ -16,7 +16,7 @@ func TestPhotoUnstack(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, r.Code)
// t.Logf("RESP: %s", r.Body.String())
})
t.Run("unstack bridge3.jpg", func(t *testing.T) {
t.Run("UnstackBridge3Jpg", func(t *testing.T) {
app, router, _ := NewApiTest()
PhotoUnstack(router)
r := PerformRequest(app, "POST", "/api/v1/photos/ps6sg6be2lvl0yh7/files/fs6sg6bwhhbnlqdn/unstack")
@@ -24,7 +24,7 @@ func TestPhotoUnstack(t *testing.T) {
assert.Equal(t, http.StatusNotFound, r.Code)
// t.Logf("RESP: %s", r.Body.String())
})
t.Run("not existing file", func(t *testing.T) {
t.Run("NotExistingFile", func(t *testing.T) {
app, router, _ := NewApiTest()
PhotoUnstack(router)
r := PerformRequest(app, "POST", "/api/v1/photos/ps6sg6be2lvl0yh7/files/xxx/unstack")

View File

@@ -19,7 +19,7 @@ func TestUploadToService(t *testing.T) {
assert.Equal(t, i18n.Msg(i18n.ErrBadRequest), val.String())
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("account not found", func(t *testing.T) {
t.Run("AccountNotFound", func(t *testing.T) {
app, router, _ := NewApiTest()
UploadToService(router)
r := PerformRequest(app, "POST", "/api/v1/services/999000/upload")

View File

@@ -191,7 +191,7 @@ func TestCreateSession(t *testing.T) {
assert.Equal(t, i18n.Msg(i18n.ErrInvalidCredentials), val.String())
assert.Equal(t, http.StatusUnauthorized, r.Code)
})
t.Run("2FAPasscodeRequired", func(t *testing.T) {
t.Run("TwoFaPasscodeRequired", func(t *testing.T) {
app, router, conf := NewApiTest()
conf.SetAuthMode(config.AuthModePasswd)
defer conf.SetAuthMode(config.AuthModePublic)
@@ -205,7 +205,7 @@ func TestCreateSession(t *testing.T) {
assert.Equal(t, "", userName.String())
assert.Equal(t, http.StatusUnauthorized, r.Code)
})
t.Run("2FAInvalidPasscode", func(t *testing.T) {
t.Run("TwoFaInvalidPasscode", func(t *testing.T) {
app, router, conf := NewApiTest()
conf.SetAuthMode(config.AuthModePasswd)
defer conf.SetAuthMode(config.AuthModePublic)
@@ -220,7 +220,7 @@ func TestCreateSession(t *testing.T) {
assert.Equal(t, "", userName.String())
assert.Equal(t, http.StatusUnauthorized, r.Code)
})
t.Run("2FAUseRecoveryCode", func(t *testing.T) {
t.Run("TwoFaUseRecoveryCode", func(t *testing.T) {
app, router, conf := NewApiTest()
conf.SetAuthMode(config.AuthModePasswd)
defer conf.SetAuthMode(config.AuthModePublic)

View File

@@ -15,7 +15,7 @@ func TestGetShares(t *testing.T) {
assert.Equal(t, http.StatusTemporaryRedirect, r.Code)
})
//TODO Why does it panic?
/*t.Run("valid token and share", func(t *testing.T) {
/*t.Run("ValidTokenAndShare", func(t *testing.T) {
app, router, _ := NewApiTest()
Shares(router)
r := PerformRequest(app, "GET", "/api/v1/4jxf3jfn2k/as6sg6bxpogaaba7")
@@ -28,7 +28,7 @@ func TestGetShares(t *testing.T) {
assert.Equal(t, http.StatusTemporaryRedirect, r.Code)
})
//TODO Why does it panic?
/*t.Run("valid token", func(t *testing.T) {
/*t.Run("ValidToken", func(t *testing.T) {
app, router, _ := NewApiTest()
Shares(router)
r := PerformRequest(app, "GET", "/api/v1/4jxf3jfn2k")

View File

@@ -97,7 +97,7 @@ func TestDislikeSubject(t *testing.T) {
}
func TestUpdateSubject(t *testing.T) {
t.Run("successful request person", func(t *testing.T) {
t.Run("SuccessfulRequestPerson", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateSubject(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/subjects/js6sg6b1qekk9jx8", `{"Name": "Updated Name"}`)

View File

@@ -8,7 +8,7 @@ import (
)
func TestGetSvg(t *testing.T) {
t.Run("photo", func(t *testing.T) {
t.Run("Photo", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -16,7 +16,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, photoIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("raw", func(t *testing.T) {
t.Run("Raw", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -24,7 +24,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, rawIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("file", func(t *testing.T) {
t.Run("File", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -32,7 +32,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, fileIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("video", func(t *testing.T) {
t.Run("Video", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -40,7 +40,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, videoIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("label", func(t *testing.T) {
t.Run("Label", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -48,7 +48,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, labelIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("album", func(t *testing.T) {
t.Run("Album", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -56,7 +56,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, albumIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("folder", func(t *testing.T) {
t.Run("Folder", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -64,7 +64,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, folderIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("broken", func(t *testing.T) {
t.Run("Broken", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)
@@ -72,7 +72,7 @@ func TestGetSvg(t *testing.T) {
assert.Equal(t, brokenIconSvg, r.Body.Bytes())
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("uncached", func(t *testing.T) {
t.Run("Uncached", func(t *testing.T) {
app, router, conf := NewApiTest()
t.Log(conf)
GetSvg(router)

View File

@@ -32,7 +32,7 @@ func TestUploadUserAvatar(t *testing.T) {
assert.Equal(t, http.StatusForbidden, r.Code)
conf.Options().DisableSettings = false
})
t.Run("bobCannotChangeAlice", func(t *testing.T) {
t.Run("BobCannotChangeAlice", func(t *testing.T) {
app, router, conf := NewApiTest()
adminUid := entity.Admin.UserUID

View File

@@ -33,26 +33,26 @@ func TestRoleStrings_String_Join(t *testing.T) {
}
func TestRoleStrings_CliUsageString(t *testing.T) {
t.Run("empty", func(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
assert.Equal(t, "", (RoleStrings{}).CliUsageString())
})
t.Run("single", func(t *testing.T) {
t.Run("Single", func(t *testing.T) {
m := RoleStrings{"admin": RoleAdmin}
assert.Equal(t, "admin", m.CliUsageString())
})
t.Run("two", func(t *testing.T) {
t.Run("Two", func(t *testing.T) {
m := RoleStrings{"guest": RoleGuest, "admin": RoleAdmin}
// Note the comma before "or" matches current implementation.
assert.Equal(t, "admin, or guest", m.CliUsageString())
})
t.Run("three", func(t *testing.T) {
t.Run("Three", func(t *testing.T) {
m := RoleStrings{"visitor": RoleVisitor, "guest": RoleGuest, "admin": RoleAdmin}
assert.Equal(t, "admin, guest, or visitor", m.CliUsageString())
})
}
func TestRoles_Allow(t *testing.T) {
t.Run("specific role grant", func(t *testing.T) {
t.Run("SpecificRoleGrant", func(t *testing.T) {
roles := Roles{
RoleVisitor: GrantViewShared, // denies delete
}
@@ -60,21 +60,21 @@ func TestRoles_Allow(t *testing.T) {
assert.True(t, roles.Allow(RoleVisitor, ActionDownload))
assert.False(t, roles.Allow(RoleVisitor, ActionDelete))
})
t.Run("default fallback used", func(t *testing.T) {
t.Run("DefaultFallbackUsed", func(t *testing.T) {
roles := Roles{
RoleDefault: GrantViewAll, // allows view, denies delete
}
assert.True(t, roles.Allow(RoleUser, ActionView))
assert.False(t, roles.Allow(RoleUser, ActionDelete))
})
t.Run("specific overrides default (no fallback)", func(t *testing.T) {
t.Run("SpecificOverridesDefaultNoFallback", func(t *testing.T) {
roles := Roles{
RoleVisitor: GrantViewShared, // denies delete
RoleDefault: GrantFullAccess, // would allow delete, must NOT be used
}
assert.False(t, roles.Allow(RoleVisitor, ActionDelete))
})
t.Run("no match and no default", func(t *testing.T) {
t.Run("NoMatchAndNoDefault", func(t *testing.T) {
roles := Roles{
RoleVisitor: GrantViewShared,
}
@@ -83,7 +83,7 @@ func TestRoles_Allow(t *testing.T) {
}
func TestRoleStrings_GlobalMaps_AliasNoneAndUsage(t *testing.T) {
t.Run("ClientRoles Strings include alias none, exclude empty", func(t *testing.T) {
t.Run("ClientRolesStringsIncludeAliasNoneExcludeEmpty", func(t *testing.T) {
got := ClientRoles.Strings()
// Contains exactly the expected elements, order not enforced.
assert.ElementsMatch(t, []string{"admin", "client", "instance", "none", "portal", "service"}, got)
@@ -92,14 +92,14 @@ func TestRoleStrings_GlobalMaps_AliasNoneAndUsage(t *testing.T) {
assert.NotEqual(t, "", s)
}
})
t.Run("UserRoles Strings include alias none, exclude empty", func(t *testing.T) {
t.Run("UserRolesStringsIncludeAliasNoneExcludeEmpty", func(t *testing.T) {
got := UserRoles.Strings()
assert.ElementsMatch(t, []string{"admin", "guest", "none", "visitor"}, got)
for _, s := range got {
assert.NotEqual(t, "", s)
}
})
t.Run("ClientRoles CliUsageString includes none and or before last", func(t *testing.T) {
t.Run("ClientRolesCliUsageStringIncludesNoneAndOrBeforeLast", func(t *testing.T) {
u := ClientRoles.CliUsageString()
// Should list known roles and end with "or none" (alias present).
for _, s := range []string{"admin", "client", "instance", "portal", "service", "none"} {
@@ -107,14 +107,14 @@ func TestRoleStrings_GlobalMaps_AliasNoneAndUsage(t *testing.T) {
}
assert.Regexp(t, `, or none$`, u)
})
t.Run("UserRoles CliUsageString includes none and or before last", func(t *testing.T) {
t.Run("UserRolesCliUsageStringIncludesNoneAndOrBeforeLast", func(t *testing.T) {
u := UserRoles.CliUsageString()
for _, s := range []string{"admin", "guest", "visitor", "none"} {
assert.Contains(t, u, s)
}
assert.Regexp(t, `, or none$`, u)
})
t.Run("Alias none maps to RoleNone", func(t *testing.T) {
t.Run("AliasNoneMapsToRoleNone", func(t *testing.T) {
assert.Equal(t, RoleNone, ClientRoles[RoleAliasNone])
assert.Equal(t, RoleNone, UserRoles[RoleAliasNone])
})

View File

@@ -8,7 +8,7 @@ import (
)
func TestClientRoleFlagUsage_IncludesNoneAlias(t *testing.T) {
t.Run("AddCommand role flag includes none", func(t *testing.T) {
t.Run("AddCommandRoleFlagIncludesNone", func(t *testing.T) {
var roleFlag *cli.StringFlag
for _, f := range ClientsAddCommand.Flags {
if rf, ok := f.(*cli.StringFlag); ok && rf.Name == "role" {
@@ -21,7 +21,7 @@ func TestClientRoleFlagUsage_IncludesNoneAlias(t *testing.T) {
}
assert.Contains(t, roleFlag.Usage, "none")
})
t.Run("ModCommand role flag includes none", func(t *testing.T) {
t.Run("ModCommandRoleFlagIncludesNone", func(t *testing.T) {
var roleFlag *cli.StringFlag
for _, f := range ClientsModCommand.Flags {
if rf, ok := f.(*cli.StringFlag); ok && rf.Name == "role" {

View File

@@ -8,7 +8,7 @@ import (
)
func TestUserRoleFlagUsage_IncludesNoneAlias(t *testing.T) {
t.Run("AddCommand user role flag includes none", func(t *testing.T) {
t.Run("AddCommandUserRoleFlagIncludesNone", func(t *testing.T) {
var roleFlag *cli.StringFlag
for _, f := range UsersAddCommand.Flags {
if rf, ok := f.(*cli.StringFlag); ok && rf.Name == "role" {
@@ -21,7 +21,7 @@ func TestUserRoleFlagUsage_IncludesNoneAlias(t *testing.T) {
}
assert.Contains(t, roleFlag.Usage, "none")
})
t.Run("ModCommand user role flag includes none", func(t *testing.T) {
t.Run("ModCommandUserRoleFlagIncludesNone", func(t *testing.T) {
var roleFlag *cli.StringFlag
for _, f := range UsersModCommand.Flags {
if rf, ok := f.(*cli.StringFlag); ok && rf.Name == "role" {

View File

@@ -57,7 +57,7 @@ func TestConfig_PortalUrl(t *testing.T) {
c.options.ClusterDomain = "foo.bar.baz"
assert.Equal(t, "https://portal.foo.bar.baz", c.PortalUrl())
})
t.Run("Substitute_PHOTOPRISM_CLUSTER_DOMAIN", func(t *testing.T) {
t.Run("SubstitutePhotoprismClusterDomain", func(t *testing.T) {
c := NewConfig(CliTestContext())
c.options.ClusterDomain = "example.dev"
// Use curly braces style as found in repo fixtures; resolver normalizes to ${...}.
@@ -65,14 +65,14 @@ func TestConfig_PortalUrl(t *testing.T) {
assert.Equal(t, "https://portal.example.dev", c.PortalUrl())
c.options.PortalUrl = DefaultPortalUrl
})
t.Run("Substitute_CLUSTER_DOMAIN", func(t *testing.T) {
t.Run("SubstituteClusterDomain", func(t *testing.T) {
c := NewConfig(CliTestContext())
c.options.ClusterDomain = "example.dev"
c.options.PortalUrl = "https://portal.${CLUSTER_DOMAIN}"
assert.Equal(t, "https://portal.example.dev", c.PortalUrl())
c.options.PortalUrl = DefaultPortalUrl
})
t.Run("Substitute_cluster_dash_domain_Curly", func(t *testing.T) {
t.Run("SubstituteClusterDashDomainCurly", func(t *testing.T) {
c := NewConfig(CliTestContext())
c.options.ClusterDomain = "example.dev"
// Curly brace variant {cluster-domain} is normalized by ExpandVars.

View File

@@ -259,7 +259,7 @@ func TestConfig_CreateDirectories(t *testing.T) {
fs_test.go:142: error expected
func TestConfig_CreateDirectories2(t *testing.T) {
t.Run("asset path not found", func(t *testing.T) {
t.Run("AssetPathNotFound", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -282,7 +282,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("storage path error", func(t *testing.T) {
t.Run("StoragePathError", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -298,7 +298,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("originals path not found", func(t *testing.T) {
t.Run("OriginalsPathNotFound", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -322,7 +322,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("import path not found", func(t *testing.T) {
t.Run("ImportPathNotFound", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -346,7 +346,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("sidecar path error", func(t *testing.T) {
t.Run("SidecarPathError", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -362,7 +362,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("cache path error", func(t *testing.T) {
t.Run("CachePathError", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -378,7 +378,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("config path error", func(t *testing.T) {
t.Run("ConfigPathError", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
@@ -394,7 +394,7 @@ func TestConfig_CreateDirectories2(t *testing.T) {
}
assert.Contains(t, err2.Error(), "check config and permissions")
})
t.Run("temp path error", func(t *testing.T) {
t.Run("TempPathError", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{

View File

@@ -41,7 +41,7 @@ func TestNewSettings(t *testing.T) {
}
func TestSettings_Load(t *testing.T) {
t.Run("existing filename", func(t *testing.T) {
t.Run("ExistingFilename", func(t *testing.T) {
s := NewDefaultSettings()
if err := s.Load("testdata/settings.yml"); err != nil {
@@ -51,7 +51,7 @@ func TestSettings_Load(t *testing.T) {
assert.Equal(t, "onyx", s.UI.Theme)
assert.Equal(t, "de", s.UI.Language)
})
t.Run("not existing filename", func(t *testing.T) {
t.Run("NotExistingFilename", func(t *testing.T) {
s := NewDefaultSettings()
err := s.Load("testdata/settings_123.yml")
@@ -63,7 +63,7 @@ func TestSettings_Load(t *testing.T) {
})
}
func TestSettings_Save(t *testing.T) {
t.Run("existing filename", func(t *testing.T) {
t.Run("ExistingFilename", func(t *testing.T) {
s := NewDefaultSettings()
assert.Equal(t, "default", s.UI.Theme)
@@ -79,7 +79,7 @@ func TestSettings_Save(t *testing.T) {
t.Fatal(err)
}
})
t.Run("not existing filename", func(t *testing.T) {
t.Run("NotExistingFilename", func(t *testing.T) {
s := NewDefaultSettings()
s.UI.Theme = "onyx"
s.UI.Language = "de"

View File

@@ -23,7 +23,7 @@ func TestCachedAlbumByUID(t *testing.T) {
t.Fatal("error expected")
}
})
t.Run("as6sg6bxpogaaba7", func(t *testing.T) {
t.Run("As6sg6bxpogaaba7", func(t *testing.T) {
if result, err := CachedAlbumByUID("as6sg6bxpogaaba7"); err != nil {
t.Fatal(err)
} else {
@@ -37,7 +37,7 @@ func TestCachedAlbumByUID(t *testing.T) {
assert.Equal(t, "christmas-2030", cached.AlbumSlug)
}
})
t.Run("as6sg6bipotaab23", func(t *testing.T) {
t.Run("As6sg6bipotaab23", func(t *testing.T) {
if result, err := CachedAlbumByUID("as6sg6bipotaab23"); err != nil {
t.Fatal(err)
} else {

View File

@@ -7,13 +7,13 @@ import (
)
func TestAlbumMap_Get(t *testing.T) {
t.Run("get existing album", func(t *testing.T) {
t.Run("GetExistingAlbum", func(t *testing.T) {
r := AlbumFixtures.Get("christmas2030")
assert.Equal(t, "as6sg6bxpogaaba7", r.AlbumUID)
assert.Equal(t, "christmas-2030", r.AlbumSlug)
assert.IsType(t, Album{}, r)
})
t.Run("get not existing album", func(t *testing.T) {
t.Run("GetNotExistingAlbum", func(t *testing.T) {
r := AlbumFixtures.Get("Fusion 3333")
assert.Equal(t, "fusion-3333", r.AlbumSlug)
assert.IsType(t, Album{}, r)
@@ -21,13 +21,13 @@ func TestAlbumMap_Get(t *testing.T) {
}
func TestAlbumMap_Pointer(t *testing.T) {
t.Run("get existing album pointer", func(t *testing.T) {
t.Run("GetExistingAlbumPointer", func(t *testing.T) {
r := AlbumFixtures.Pointer("christmas2030")
assert.Equal(t, "as6sg6bxpogaaba7", r.AlbumUID)
assert.Equal(t, "christmas-2030", r.AlbumSlug)
assert.IsType(t, &Album{}, r)
})
t.Run("get not existing album pointer", func(t *testing.T) {
t.Run("GetNotExistingAlbumPointer", func(t *testing.T) {
r := AlbumFixtures.Pointer("Fusion 444")
assert.Equal(t, "fusion-444", r.AlbumSlug)
assert.IsType(t, &Album{}, r)

View File

@@ -494,7 +494,7 @@ func TestAlbum_String(t *testing.T) {
}
func TestAlbum_IsMoment(t *testing.T) {
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
album := Album{
AlbumUID: "abc123",
AlbumSlug: "test-slug",
@@ -503,7 +503,7 @@ func TestAlbum_IsMoment(t *testing.T) {
}
assert.False(t, album.IsMoment())
})
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
album := Album{
AlbumUID: "abc123",
AlbumSlug: "test-slug",
@@ -1047,13 +1047,13 @@ func TestAlbum_Title(t *testing.T) {
}
func TestAlbum_ZipName(t *testing.T) {
t.Run("christmas-2030.zip", func(t *testing.T) {
t.Run("ChristmasNum2030Zip", func(t *testing.T) {
album := AlbumFixtures.Get("christmas2030")
result := album.ZipName()
assert.Equal(t, "christmas-2030.zip", result)
})
t.Run("photoprism-album-1234.zip", func(t *testing.T) {
t.Run("PhotoprismAlbumNum1234Zip", func(t *testing.T) {
album := Album{AlbumSlug: "a", AlbumUID: "1234"}
result := album.ZipName()

View File

@@ -11,7 +11,7 @@ import (
)
func TestAlbum_Yaml(t *testing.T) {
t.Run("berlin-2019", func(t *testing.T) {
t.Run("BerlinNum2019", func(t *testing.T) {
m := AlbumFixtures.Get("berlin-2019")
if found := m.Find(); found == nil {
@@ -28,7 +28,7 @@ func TestAlbum_Yaml(t *testing.T) {
t.Logf("YAML: %s", result)
})
t.Run("christmas2030", func(t *testing.T) {
t.Run("Christmas2030", func(t *testing.T) {
m := AlbumFixtures.Get("christmas2030")
if found := m.Find(); found == nil {
@@ -201,7 +201,7 @@ func TestAlbum_SaveBackupYaml(t *testing.T) {
}
func TestAlbum_LoadFromYaml(t *testing.T) {
t.Run("berlin-2020", func(t *testing.T) {
t.Run("BerlinNum2020", func(t *testing.T) {
fileName := "testdata/album/as6sg6bxpoaaaaaa.yml"
m := Album{}

View File

@@ -160,7 +160,7 @@ func TestClient_User(t *testing.T) {
}
func TestClient_SetUser(t *testing.T) {
t.Run("john", func(t *testing.T) {
t.Run("John", func(t *testing.T) {
c := Client{ClientName: "test"}
u := &User{UserUID: "uqxc08w3d0ej2111", UserName: "john"}

View File

@@ -148,7 +148,7 @@ func TestFindSession(t *testing.T) {
}
func TestCacheSession(t *testing.T) {
t.Run("bob", func(t *testing.T) {
t.Run("Bob", func(t *testing.T) {
sessionCache.Flush()
r, b := sessionCache.Get(rnd.SessionID("69be27ac5ca305b394046a83f6fda18167ca3d3f2dbe7ac1"))
assert.Empty(t, r)
@@ -163,7 +163,7 @@ func TestCacheSession(t *testing.T) {
assert.Empty(t, r3)
assert.False(t, b3)
})
t.Run("duration 0", func(t *testing.T) {
t.Run("DurationZero", func(t *testing.T) {
r, b := sessionCache.Get(rnd.SessionID("69be27ac5ca305b394046a83f6fda18167ca3d3f2dbe7ac0"))
assert.Empty(t, r)
assert.False(t, b)
@@ -174,7 +174,7 @@ func TestCacheSession(t *testing.T) {
assert.True(t, b2)
sessionCache.Flush()
})
t.Run("invalid ID", func(t *testing.T) {
t.Run("InvalidId", func(t *testing.T) {
r, b := sessionCache.Get("xxx")
assert.Empty(t, r)
assert.False(t, b)

View File

@@ -25,7 +25,7 @@ func TestDeleteSession(t *testing.T) {
r2, _ := sessionCache.Get(id)
assert.Empty(t, r2)
})
t.Run("invalidID", func(t *testing.T) {
t.Run("InvalidId", func(t *testing.T) {
m := &Session{ID: "123-invalid", DownloadToken: "download123", PreviewToken: "preview123"}
CacheSession(m, time.Hour)

View File

@@ -76,7 +76,7 @@ func TestSession_SetData(t *testing.T) {
}
func TestSession_Expires(t *testing.T) {
t.Run("Set expiry date", func(t *testing.T) {
t.Run("SetExpiryDate", func(t *testing.T) {
m := NewSession(unix.Day, unix.Hour)
initialExpiryDate := m.SessExpires
m.Expires(time.Date(2035, 01, 15, 12, 30, 0, 0, time.UTC))
@@ -84,7 +84,7 @@ func TestSession_Expires(t *testing.T) {
assert.Greater(t, finalExpiryDate, initialExpiryDate)
})
t.Run("Try to set zero date", func(t *testing.T) {
t.Run("TryToSetZeroDate", func(t *testing.T) {
m := NewSession(unix.Day, unix.Hour)
initialExpiryDate := m.SessExpires
m.Expires(time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC))
@@ -115,7 +115,7 @@ func TestFindSessionByRefID(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
assert.Nil(t, FindSessionByRefID(""))
})
t.Run("alice", func(t *testing.T) {
t.Run("Alice", func(t *testing.T) {
m := FindSessionByRefID("sessxkkcabcd")
assert.Equal(t, "alice", m.UserName)
assert.IsType(t, &Session{}, m)
@@ -209,7 +209,7 @@ func TestSession_Create(t *testing.T) {
m2 := FindSessionByRefID("sessxkkcxxxx")
assert.Equal(t, "charles", m2.UserName)
})
t.Run("Invalid RefID", func(t *testing.T) {
t.Run("InvalidRefId", func(t *testing.T) {
authToken := "69be27ac5ca305b394046a83f6fda18167ca3d3f2dbe7111"
id := rnd.SessionID("69be27ac5ca305b394046a83f6fda18167ca3d3f2dbe7111")
@@ -236,7 +236,7 @@ func TestSession_Create(t *testing.T) {
assert.NotEqual(t, "123", m2.RefID)
})
t.Run("ID already exists", func(t *testing.T) {
t.Run("IdAlreadyExists", func(t *testing.T) {
authToken := "69be27ac5ca305b394046a83f6fda18167ca3d3f2dbe7ac0"
s := &Session{
@@ -397,7 +397,7 @@ func TestSession_SetClientName(t *testing.T) {
assert.Equal(t, "Foo Bar!", m.GetClientName())
assert.Equal(t, "Foo Bar!", m.GetClientInfo())
})
t.Run("setNewID", func(t *testing.T) {
t.Run("SetNewId", func(t *testing.T) {
m := NewSession(0, 0)
assert.Equal(t, "", m.ClientUID)
assert.Equal(t, "", m.GetClientName())
@@ -467,14 +467,14 @@ func TestSession_RefreshUser(t *testing.T) {
}
func TestSession_AuthInfo(t *testing.T) {
t.Run("bob", func(t *testing.T) {
t.Run("Bob", func(t *testing.T) {
m := FindSessionByRefID("sessxkkcabce")
i := m.GetAuthInfo()
assert.Equal(t, "Default", i)
})
t.Run("aliceTokenWebDAV", func(t *testing.T) {
t.Run("AliceTokenWebDav", func(t *testing.T) {
m := FindSessionByRefID("sesshjtgx8qt")
i := m.GetAuthInfo()
@@ -550,7 +550,7 @@ func TestSession_SetMethod(t *testing.T) {
assert.Equal(t, authn.ProviderAccessToken, m.GetProvider())
assert.Equal(t, authn.MethodSession, m.GetMethod())
})
t.Run("2FA", func(t *testing.T) {
t.Run("TwoFa", func(t *testing.T) {
s := &Session{
UserName: "test",
RefID: "sessxkkcxxxz",
@@ -752,7 +752,7 @@ func TestSession_SetPreviewToken(t *testing.T) {
m.SetPreviewToken("12345")
assert.Equal(t, "12345", m.PreviewToken)
})
t.Run("ID empty", func(t *testing.T) {
t.Run("IdEmpty", func(t *testing.T) {
m := &Session{ID: ""}
m.SetPreviewToken("12345")
assert.Equal(t, "", m.PreviewToken)
@@ -765,7 +765,7 @@ func TestSession_SetDownloadToken(t *testing.T) {
m.SetDownloadToken("12345")
assert.Equal(t, "12345", m.DownloadToken)
})
t.Run("ID empty", func(t *testing.T) {
t.Run("IdEmpty", func(t *testing.T) {
m := &Session{ID: ""}
m.SetDownloadToken("12345")
assert.Equal(t, "", m.DownloadToken)
@@ -864,7 +864,7 @@ func TestSession_SharedUIDs(t *testing.T) {
}
func TestSession_RedeemToken(t *testing.T) {
t.Run("bob", func(t *testing.T) {
t.Run("Bob", func(t *testing.T) {
bob := FindSessionByRefID("sessxkkcabce")
bob.RefreshUser()
bob.GetUser().RefreshShares()
@@ -874,7 +874,7 @@ func TestSession_RedeemToken(t *testing.T) {
bob.GetUser().RefreshShares()
assert.Equal(t, "as6sg6bxpogaaba8", bob.GetUser().UserShares[0].ShareUID)
})
t.Run("Empty session", func(t *testing.T) {
t.Run("EmptySession", func(t *testing.T) {
m := &Session{}
assert.Equal(t, 0, m.RedeemToken("1234"))
})
@@ -992,7 +992,7 @@ func TestSession_Expired(t *testing.T) {
}
func TestSession_SetUserAgent(t *testing.T) {
t.Run("user agent empty", func(t *testing.T) {
t.Run("UserAgentEmpty", func(t *testing.T) {
m := &Session{}
assert.Equal(t, "", m.UserAgent)
m.SetUserAgent("")
@@ -1000,7 +1000,7 @@ func TestSession_SetUserAgent(t *testing.T) {
m.SetUserAgent(" ")
assert.Equal(t, "", m.UserAgent)
})
t.Run("change user agent", func(t *testing.T) {
t.Run("ChangeUserAgent", func(t *testing.T) {
m := &Session{}
assert.Equal(t, "", m.UserAgent)
m.SetUserAgent("chrome")
@@ -1011,7 +1011,7 @@ func TestSession_SetUserAgent(t *testing.T) {
}
func TestSession_SetClientIP(t *testing.T) {
t.Run("ip empty", func(t *testing.T) {
t.Run("IpEmpty", func(t *testing.T) {
m := &Session{}
assert.Equal(t, "", m.ClientIP)
m.SetClientIP("")
@@ -1019,7 +1019,7 @@ func TestSession_SetClientIP(t *testing.T) {
m.SetClientIP(" ")
assert.Equal(t, "", m.ClientIP)
})
t.Run("change ip", func(t *testing.T) {
t.Run("ChangeIp", func(t *testing.T) {
m := &Session{}
assert.Equal(t, "", m.ClientIP)
m.SetClientIP("1234")

View File

@@ -7,7 +7,7 @@ import (
)
func TestCreateUserDetails(t *testing.T) {
t.Run("Empty UID", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
m := &User{UserUID: ""}
assert.Error(t, CreateUserDetails(m))
assert.Nil(t, m.UserDetails)
@@ -46,7 +46,7 @@ func TestUserDetails_Updates(t *testing.T) {
}
func TestUserDetails_DisplayName(t *testing.T) {
t.Run("Dr. John Doe", func(t *testing.T) {
t.Run("DrJohnDoe", func(t *testing.T) {
m := &User{
UserUID: "1234",
UserDetails: &UserDetails{

View File

@@ -9,7 +9,7 @@ import (
)
func TestCreateUserSettings(t *testing.T) {
t.Run("Empty UID", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
m := &User{UserUID: ""}
assert.Error(t, CreateUserSettings(m))
assert.Nil(t, m.UserSettings)

View File

@@ -95,7 +95,7 @@ func TestFindUserShares(t *testing.T) {
assert.Equal(t, expected.UserUID, m.UserUID)
assert.Equal(t, expected.ShareUID, m.ShareUID)
})
t.Run("Invalid uid", func(t *testing.T) {
t.Run("InvalidUid", func(t *testing.T) {
found := FindUserShares("123")
assert.IsType(t, UserShares{}, found)
assert.Empty(t, found)
@@ -134,7 +134,7 @@ func TestUserShare_UpdateLink(t *testing.T) {
assert.Equal(t, "ss62xpryd1ob8xxx", m.LinkUID)
assert.Equal(t, "Wedding", m.Comment)
})
t.Run("UID mismatch", func(t *testing.T) {
t.Run("UidMismatch", func(t *testing.T) {
m := UserShare{
ShareUID: "as6sg6bxpogaaba9",
}

View File

@@ -324,7 +324,7 @@ func TestUser_UpdateUsername(t *testing.T) {
}
func TestUser_SetUsername(t *testing.T) {
t.Run("photoprism", func(t *testing.T) {
t.Run("PhotoPrism", func(t *testing.T) {
m := FindUserByName("admin")
if m == nil {
@@ -341,19 +341,19 @@ func TestUser_SetUsername(t *testing.T) {
assert.Equal(t, "photoprism", m.Username())
assert.Equal(t, "photoprism", m.UserName)
})
t.Run("system users cannot be modified", func(t *testing.T) {
t.Run("SystemUsersCannotBeModified", func(t *testing.T) {
assert.Equal(t, "system users cannot be modified", Visitor.SetUsername("newname").Error())
})
t.Run("username is empty", func(t *testing.T) {
t.Run("UsernameIsEmpty", func(t *testing.T) {
assert.Equal(t, "username is empty", Admin.SetUsername("").Error())
})
t.Run("same name", func(t *testing.T) {
t.Run("SameName", func(t *testing.T) {
assert.Nil(t, Admin.SetUsername("admin"))
})
}
func TestUser_InvalidPassword(t *testing.T) {
t.Run("admin", func(t *testing.T) {
t.Run("Admin", func(t *testing.T) {
m := FindUserByName("admin")
if m == nil {
@@ -362,7 +362,7 @@ func TestUser_InvalidPassword(t *testing.T) {
assert.False(t, m.InvalidPassword("photoprism"))
})
t.Run("admin invalid password", func(t *testing.T) {
t.Run("AdminInvalidPassword", func(t *testing.T) {
m := FindUserByName("admin")
if m == nil {
@@ -371,7 +371,7 @@ func TestUser_InvalidPassword(t *testing.T) {
assert.True(t, m.InvalidPassword("wrong-password"))
})
t.Run("no password existing", func(t *testing.T) {
t.Run("NoPasswordExisting", func(t *testing.T) {
p := User{UserUID: "u000000000000010", UserName: "Hans", DisplayName: ""}
err := p.Save()
if err != nil {
@@ -983,7 +983,7 @@ func TestAddUser(t *testing.T) {
err := AddUser(u)
assert.Error(t, err)
})
t.Run("Invalid Role", func(t *testing.T) {
t.Run("InvalidRole", func(t *testing.T) {
u := form.User{
UserName: "thomas4",
UserEmail: "thomas4@example.com",
@@ -1057,7 +1057,7 @@ func TestDeleteUser(t *testing.T) {
err := u.Delete()
assert.Error(t, err)
})
t.Run("Empty UID", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
u := NewUser()
u.UserUID = ""
u.ID = 500
@@ -1104,7 +1104,7 @@ func TestUser_UpdateLoginTime(t *testing.T) {
assert.NotNil(t, time3)
assert.True(t, time3.After(*time2) || time3.Equal(*time2))
})
t.Run("User deleted", func(t *testing.T) {
t.Run("UserDeleted", func(t *testing.T) {
u := NewUser()
var deleted = time.Date(2020, 3, 6, 2, 6, 51, 0, time.UTC)
u.DeletedAt = &deleted
@@ -1123,13 +1123,13 @@ func TestUser_CanLogIn(t *testing.T) {
assert.False(t, UserFixtures.Pointer("deleted").CanLogIn())
})
t.Run("False - !canlogin", func(t *testing.T) {
t.Run("FalseCanlogin", func(t *testing.T) {
u := NewUser()
u.AuthProvider = "local"
u.CanLogin = false
assert.False(t, u.CanLogIn())
})
t.Run("False - unknown role", func(t *testing.T) {
t.Run("FalseUnknownRole", func(t *testing.T) {
unknown := UserFixtures.Get("unauthorized")
assert.False(t, unknown.CanLogIn())
unknown.SetProvider(authn.ProviderLocal)
@@ -1205,7 +1205,7 @@ func TestUser_Form(t *testing.T) {
}
func TestUser_PrivilegeLevelChange(t *testing.T) {
t.Run("True - Role changed", func(t *testing.T) {
t.Run("TrueRoleChanged", func(t *testing.T) {
m := FindUserByName("alice")
if m == nil {
@@ -1222,7 +1222,7 @@ func TestUser_PrivilegeLevelChange(t *testing.T) {
assert.True(t, m.PrivilegeLevelChange(frm))
})
t.Run("True - Path changed", func(t *testing.T) {
t.Run("TruePathChanged", func(t *testing.T) {
m := FindUserByName("alice")
if m == nil {
@@ -1239,7 +1239,7 @@ func TestUser_PrivilegeLevelChange(t *testing.T) {
assert.True(t, m.PrivilegeLevelChange(frm))
})
t.Run("True - CanLogin changed", func(t *testing.T) {
t.Run("TrueCanLoginChanged", func(t *testing.T) {
m := FindUserByName("alice")
if m == nil {
@@ -1256,7 +1256,7 @@ func TestUser_PrivilegeLevelChange(t *testing.T) {
assert.True(t, m.PrivilegeLevelChange(frm))
})
t.Run("True - Webdav changed", func(t *testing.T) {
t.Run("TrueWebdavChanged", func(t *testing.T) {
m := FindUserByName("alice")
if m == nil {
@@ -1273,7 +1273,7 @@ func TestUser_PrivilegeLevelChange(t *testing.T) {
assert.True(t, m.PrivilegeLevelChange(frm))
})
t.Run("False - Name changed", func(t *testing.T) {
t.Run("FalseNameChanged", func(t *testing.T) {
m := FindUserByName("alice")
if m == nil {
@@ -1290,7 +1290,7 @@ func TestUser_PrivilegeLevelChange(t *testing.T) {
assert.False(t, m.PrivilegeLevelChange(frm))
})
t.Run("False - No change", func(t *testing.T) {
t.Run("FalseNoChange", func(t *testing.T) {
m := FindUserByName("alice")
if m == nil {
@@ -1588,7 +1588,7 @@ func TestUser_SetDisplayName(t *testing.T) {
assert.Equal(t, "Henry Gates", d.FamilyName)
assert.Equal(t, "III", d.NameSuffix)
})
t.Run("Empty Name", func(t *testing.T) {
t.Run("EmptyName", func(t *testing.T) {
user := NewUser()
user.SetDisplayName("", SrcAuto)
d := user.Details()
@@ -1597,7 +1597,7 @@ func TestUser_SetDisplayName(t *testing.T) {
assert.Equal(t, "", d.FamilyName)
assert.Equal(t, "", d.NameSuffix)
})
t.Run("priority too low", func(t *testing.T) {
t.Run("PriorityTooLow", func(t *testing.T) {
user := User{
ID: 1234567,
UserUID: "urqdrfb72479n047",
@@ -1675,7 +1675,7 @@ func TestUser_SetAvatar(t *testing.T) {
assert.Equal(t, SrcManual, m.ThumbSrc)
assert.True(t, Admin.HasAvatar())
})
t.Run("No permissions", func(t *testing.T) {
t.Run("NoPermissions", func(t *testing.T) {
err := Admin.SetAvatar("ebfc0aea7d3fd018b5fff57c76806b35181855ed", SrcAuto)
assert.Error(t, err)
})
@@ -1709,7 +1709,7 @@ func TestUser_Provider(t *testing.T) {
assert.Equal(t, authn.ProviderLocal, Admin.Provider())
Admin.SetProvider(authn.ProviderLocal)
})
t.Run("Username empty", func(t *testing.T) {
t.Run("UsernameEmpty", func(t *testing.T) {
user := NewUser()
user.ID = 500
user.AuthProvider = ""
@@ -1719,7 +1719,7 @@ func TestUser_Provider(t *testing.T) {
}
func TestUser_SetProvider(t *testing.T) {
t.Run("2FA", func(t *testing.T) {
t.Run("TwoFa", func(t *testing.T) {
m := UserFixtures.Get("alice")
assert.Equal(t, authn.ProviderLocal, m.Provider())
assert.Equal(t, authn.MethodDefault, m.Method())
@@ -1734,7 +1734,7 @@ func TestUser_SetProvider(t *testing.T) {
}
func TestUser_SetMethod(t *testing.T) {
t.Run("2FA", func(t *testing.T) {
t.Run("TwoFa", func(t *testing.T) {
m := UserFixtures.Get("unauthorized")
assert.Equal(t, authn.ProviderNone, m.Provider())
assert.Equal(t, authn.MethodDefault, m.Method())
@@ -1859,14 +1859,14 @@ func TestUser_GetUploadPath(t *testing.T) {
t.Run("Admin", func(t *testing.T) {
assert.Equal(t, "", Admin.GetUploadPath())
})
t.Run("Use base path", func(t *testing.T) {
t.Run("UseBasePath", func(t *testing.T) {
user := NewUser()
user.UserName = "test"
user.UploadPath = "./"
user.BasePath = "mybase"
assert.Equal(t, "mybase", user.GetUploadPath())
})
t.Run("Upload path includes base path", func(t *testing.T) {
t.Run("UploadPathIncludesBasePath", func(t *testing.T) {
user := NewUser()
user.UserName = "test"
user.UploadPath = "mybase/upload"
@@ -1958,7 +1958,7 @@ func TestUser_FullName(t *testing.T) {
assert.Equal(t, "Jane Doe", u.FullName())
})
t.Run("Name from Details", func(t *testing.T) {
t.Run("NameFromDetails", func(t *testing.T) {
u := User{
ID: 1234567,
UserUID: "urqdrfb72479n047",
@@ -1998,7 +1998,7 @@ func TestUser_FullName(t *testing.T) {
}
func TestUser_Settings(t *testing.T) {
t.Run("return settings", func(t *testing.T) {
t.Run("ReturnSettings", func(t *testing.T) {
u := User{
ID: 1234567,
UserUID: "urqdrfb72479n047",
@@ -2016,7 +2016,7 @@ func TestUser_Settings(t *testing.T) {
assert.Equal(t, "de", u.Settings().UILanguage)
assert.Equal(t, "vanta", u.Settings().UITheme)
})
t.Run("empty uid", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
u := User{
ID: 1234567,
UserUID: "",
@@ -2030,7 +2030,7 @@ func TestUser_Settings(t *testing.T) {
}
func TestUser_Details(t *testing.T) {
t.Run("return details", func(t *testing.T) {
t.Run("ReturnDetails", func(t *testing.T) {
u := User{
ID: 1234567,
UserUID: "urqdrfb72479n047",
@@ -2045,7 +2045,7 @@ func TestUser_Details(t *testing.T) {
assert.Equal(t, "John", u.Details().GivenName)
assert.Equal(t, "Doe", u.Details().FamilyName)
})
t.Run("empty uid", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
u := User{
ID: 1234567,
UserUID: "",
@@ -2064,7 +2064,7 @@ func TestUser_Equal(t *testing.T) {
}
func TestUser_DeleteSessions(t *testing.T) {
t.Run("empty uid", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
u := User{
ID: 1234567,
UserUID: "",
@@ -2074,7 +2074,7 @@ func TestUser_DeleteSessions(t *testing.T) {
assert.Equal(t, 0, u.DeleteSessions([]string{}))
})
t.Run("alice", func(t *testing.T) {
t.Run("Alice", func(t *testing.T) {
m := FindLocalUser("alice")
assert.Equal(t, 0, m.DeleteSessions([]string{rnd.SessionID("69be27ac5ca305b394046a83f6fda18167ca3d3f2dbe7ac0")}))

View File

@@ -7,13 +7,13 @@ import (
)
func TestCameraMap_Get(t *testing.T) {
t.Run("get existing camera", func(t *testing.T) {
t.Run("GetExistingCamera", func(t *testing.T) {
r := CameraFixtures.Get("apple-iphone-se")
assert.Equal(t, uint(0xf4240), r.ID)
assert.Equal(t, "iPhone SE", r.CameraModel)
assert.IsType(t, Camera{}, r)
})
t.Run("get not existing camera", func(t *testing.T) {
t.Run("GetNotExistingCamera", func(t *testing.T) {
r := CameraFixtures.Get("fantasy Cam")
assert.Equal(t, "fantasy-cam", r.CameraSlug)
assert.IsType(t, Camera{}, r)
@@ -21,13 +21,13 @@ func TestCameraMap_Get(t *testing.T) {
}
func TestCameraMap_Pointer(t *testing.T) {
t.Run("get existing camera pointer", func(t *testing.T) {
t.Run("GetExistingCameraPointer", func(t *testing.T) {
r := CameraFixtures.Pointer("apple-iphone-se")
assert.Equal(t, uint(0xf4240), r.ID)
assert.Equal(t, "iPhone SE", r.CameraModel)
assert.IsType(t, &Camera{}, r)
})
t.Run("get not existing camera pointer", func(t *testing.T) {
t.Run("GetNotExistingCameraPointer", func(t *testing.T) {
r := CameraFixtures.Pointer("GOPRO")
assert.Equal(t, "gopro", r.CameraSlug)
assert.IsType(t, &Camera{}, r)

View File

@@ -24,7 +24,7 @@ func TestFirstOrCreateCamera(t *testing.T) {
assert.Equal(t, uint(1), result.ID)
assert.Equal(t, UnknownID, result.CameraSlug)
})
t.Run("existing camera", func(t *testing.T) {
t.Run("ExistingCamera", func(t *testing.T) {
camera := NewCamera("Apple", "iPhone SE")
result := FirstOrCreateCamera(camera)
@@ -35,7 +35,7 @@ func TestFirstOrCreateCamera(t *testing.T) {
assert.GreaterOrEqual(t, result.ID, uint(1))
})
t.Run("not existing camera", func(t *testing.T) {
t.Run("NotExistingCamera", func(t *testing.T) {
camera := &Camera{ID: 10000000, CameraSlug: "camera-slug"}
result := FirstOrCreateCamera(camera)
@@ -201,7 +201,7 @@ func TestCamera_Mobile(t *testing.T) {
assert.False(t, camera.Scanner())
assert.False(t, camera.Mobile())
})
t.Run("iPhone", func(t *testing.T) {
t.Run("IPhone", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPhone)
assert.Equal(t, CameraTypePhone, camera.CameraType)
assert.Equal(t, MakeApple+" "+ModelIPhone, camera.CameraName)
@@ -210,7 +210,7 @@ func TestCamera_Mobile(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("iPad", func(t *testing.T) {
t.Run("IPad", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPad)
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeApple+" "+ModelIPad, camera.CameraName)
@@ -219,7 +219,7 @@ func TestCamera_Mobile(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("iPadAir", func(t *testing.T) {
t.Run("IPadAir", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPadAir)
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeApple, camera.CameraMake)
@@ -227,7 +227,7 @@ func TestCamera_Mobile(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("iPadPro", func(t *testing.T) {
t.Run("IPadPro", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPadPro)
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeApple, camera.CameraMake)

View File

@@ -41,7 +41,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.False(t, camera.Scanner())
assert.False(t, camera.Mobile())
})
t.Run("iPhone", func(t *testing.T) {
t.Run("IPhone", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPhone)
assert.Equal(t, CameraTypePhone, camera.CameraType)
assert.Equal(t, MakeApple+" "+ModelIPhone, camera.CameraName)
@@ -50,7 +50,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("iPad", func(t *testing.T) {
t.Run("IPad", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPad)
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeApple+" "+ModelIPad, camera.CameraName)
@@ -59,7 +59,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("iPadAir", func(t *testing.T) {
t.Run("IPadAir", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPadAir)
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeApple, camera.CameraMake)
@@ -67,7 +67,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("iPadPro", func(t *testing.T) {
t.Run("IPadPro", func(t *testing.T) {
camera := NewCamera(MakeApple, ModelIPadPro)
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeApple, camera.CameraMake)
@@ -227,7 +227,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.True(t, camera.Scanner())
assert.False(t, camera.Mobile())
})
t.Run("ILCE-7M3K", func(t *testing.T) {
t.Run("IlceSevenMThreeK", func(t *testing.T) {
camera := NewCamera(MakeSony, "ILCE-7M3K")
assert.Equal(t, CameraTypeBody, camera.CameraType)
assert.Equal(t, MakeSony, camera.CameraMake)
@@ -243,7 +243,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.False(t, camera.Scanner())
assert.True(t, camera.Mobile())
})
t.Run("ZV-1M2", func(t *testing.T) {
t.Run("ZvOneMTwo", func(t *testing.T) {
camera := NewCamera(MakeSony, "ZV-1M2")
assert.Equal(t, CameraTypeCompact, camera.CameraType)
assert.Equal(t, MakeSony, camera.CameraMake)
@@ -251,7 +251,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.False(t, camera.Scanner())
assert.False(t, camera.Mobile())
})
t.Run("MatePadPro12.2", func(t *testing.T) {
t.Run("MatePadProTwelveTwo", func(t *testing.T) {
camera := NewCamera(MakeHuawei, "MatePad pro 12.2")
assert.Equal(t, CameraTypeTablet, camera.CameraType)
assert.Equal(t, MakeHuawei, camera.CameraMake)
@@ -307,7 +307,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.True(t, camera.Scanner())
assert.False(t, camera.Mobile())
})
t.Run("Epson Perfection", func(t *testing.T) {
t.Run("EpsonPerfection", func(t *testing.T) {
camera := NewCamera("EPSON", "Perfection V800/V850")
assert.Equal(t, CameraTypeScanner, camera.CameraType)
assert.Equal(t, "EPSON", camera.CameraMake)
@@ -315,7 +315,7 @@ func TestCamera_CameraType(t *testing.T) {
assert.True(t, camera.Scanner())
assert.False(t, camera.Mobile())
})
t.Run("Epson FastFoto", func(t *testing.T) {
t.Run("EpsonFastFoto", func(t *testing.T) {
camera := NewCamera("EPSON", "FastFoto FF-680W")
assert.Equal(t, CameraTypeScanner, camera.CameraType)
assert.Equal(t, "EPSON", camera.CameraMake)

View File

@@ -7,13 +7,13 @@ import (
)
func TestLocationMap_Get(t *testing.T) {
t.Run("get existing location", func(t *testing.T) {
t.Run("GetExistingLocation", func(t *testing.T) {
r := CellFixtures.Get("mexico")
assert.Equal(t, "Adosada Platform", r.CellName)
assert.Equal(t, "s2:85d1ea7d382c", r.ID)
assert.IsType(t, Cell{}, r)
})
t.Run("get not existing location", func(t *testing.T) {
t.Run("GetNotExistingLocation", func(t *testing.T) {
r := CellFixtures.Get("Fusion 3333")
assert.Equal(t, UnknownID, r.ID)
assert.IsType(t, Cell{}, r)
@@ -21,13 +21,13 @@ func TestLocationMap_Get(t *testing.T) {
}
func TestLocationMap_Pointer(t *testing.T) {
t.Run("get existing location pointer", func(t *testing.T) {
t.Run("GetExistingLocationPointer", func(t *testing.T) {
r := CellFixtures.Pointer("mexico")
assert.Equal(t, "Adosada Platform", r.CellName)
assert.Equal(t, "s2:85d1ea7d382c", r.ID)
assert.IsType(t, &Cell{}, r)
})
t.Run("get not existing location pointer", func(t *testing.T) {
t.Run("GetNotExistingLocationPointer", func(t *testing.T) {
r := CellFixtures.Pointer("Fusion 444")
assert.Equal(t, UnknownID, r.ID)
assert.IsType(t, &Cell{}, r)

View File

@@ -34,7 +34,7 @@ func TestNewCell(t *testing.T) {
}
func TestCell_Keywords(t *testing.T) {
t.Run("mexico", func(t *testing.T) {
t.Run("Mexico", func(t *testing.T) {
m := CellFixtures["mexico"]
r := m.Keywords()
assert.Equal(t, []string{"adosada", "ancient", "botanical", "garden", "mexico", "platform", "pyramid", "state-of-mexico", "teotihuacán"}, r)

View File

@@ -7,12 +7,12 @@ import (
)
func TestNewCountry(t *testing.T) {
t.Run("unknown country", func(t *testing.T) {
t.Run("UnknownCountry", func(t *testing.T) {
country := NewCountry("", "")
assert.Equal(t, &UnknownCountry, country)
})
t.Run("United States", func(t *testing.T) {
t.Run("UnitedStates", func(t *testing.T) {
country := NewCountry("us", "United States")
assert.Equal(t, "United States", country.CountryName)
@@ -27,14 +27,14 @@ func TestNewCountry(t *testing.T) {
}
func TestFirstOrCreateCountry(t *testing.T) {
t.Run("es", func(t *testing.T) {
t.Run("Es", func(t *testing.T) {
country := NewCountry("es", "spain")
country = FirstOrCreateCountry(country)
if country == nil {
t.Fatal("country should not be nil")
}
})
t.Run("de", func(t *testing.T) {
t.Run("De", func(t *testing.T) {
country := &Country{ID: "de"}
r := FirstOrCreateCountry(country)
if r == nil {

View File

@@ -7,13 +7,13 @@ import (
)
func TestDescriptionMap_Get(t *testing.T) {
t.Run("get existing description", func(t *testing.T) {
t.Run("GetExistingDescription", func(t *testing.T) {
r := DetailsFixtures.Get("lake", 1000000)
assert.Equal(t, uint(1000000), r.PhotoID)
assert.Equal(t, "nature, frog", r.Keywords)
assert.IsType(t, Details{}, r)
})
t.Run("get not existing description", func(t *testing.T) {
t.Run("GetNotExistingDescription", func(t *testing.T) {
r := DetailsFixtures.Get("fantasy description", 123)
assert.Equal(t, uint(123), r.PhotoID)
assert.Equal(t, "", r.Keywords)
@@ -22,13 +22,13 @@ func TestDescriptionMap_Get(t *testing.T) {
}
func TestDescriptionMap_Pointer(t *testing.T) {
t.Run("get existing description pointer", func(t *testing.T) {
t.Run("GetExistingDescriptionPointer", func(t *testing.T) {
r := DetailsFixtures.Pointer("lake", 1000000)
assert.Equal(t, uint(1000000), r.PhotoID)
assert.Equal(t, "nature, frog", r.Keywords)
assert.IsType(t, &Details{}, r)
})
t.Run("get not existing description pointer", func(t *testing.T) {
t.Run("GetNotExistingDescriptionPointer", func(t *testing.T) {
r := DetailsFixtures.Pointer("fantasy 2", 345)
assert.Equal(t, uint(345), r.PhotoID)
assert.Equal(t, "", r.Keywords)

View File

@@ -8,7 +8,7 @@ import (
)
func TestFirstOrCreateDetails(t *testing.T) {
t.Run("not existing details", func(t *testing.T) {
t.Run("NotExistingDetails", func(t *testing.T) {
details := &Details{PhotoID: 123, Keywords: ""}
details = FirstOrCreateDetails(details)
@@ -16,7 +16,7 @@ func TestFirstOrCreateDetails(t *testing.T) {
t.Fatal("details should not be nil")
}
})
t.Run("existing details", func(t *testing.T) {
t.Run("ExistingDetails", func(t *testing.T) {
details := &Details{PhotoID: 1000000}
details = FirstOrCreateDetails(details)
@@ -31,13 +31,13 @@ func TestFirstOrCreateDetails(t *testing.T) {
}
func TestDetails_NoKeywords(t *testing.T) {
t.Run("no keywords", func(t *testing.T) {
t.Run("NoKeywords", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: ""}
assert.Equal(t, true, description.NoKeywords())
assert.False(t, description.HasKeywords())
})
t.Run("keywords", func(t *testing.T) {
t.Run("Keywords", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "test cat dog", Subject: "animals", Artist: "Bender", Notes: "notes", Copyright: "copy"}
assert.Equal(t, false, description.NoKeywords())
@@ -46,13 +46,13 @@ func TestDetails_NoKeywords(t *testing.T) {
}
func TestDetails_NoSubject(t *testing.T) {
t.Run("no subject", func(t *testing.T) {
t.Run("NoSubject", func(t *testing.T) {
description := &Details{PhotoID: 123, Subject: ""}
assert.Equal(t, true, description.NoSubject())
assert.False(t, description.HasSubject())
})
t.Run("subject", func(t *testing.T) {
t.Run("Subject", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "test cat dog", Subject: "animals", Artist: "Bender", Notes: "notes", Copyright: "copy"}
assert.Equal(t, false, description.NoSubject())
@@ -61,13 +61,13 @@ func TestDetails_NoSubject(t *testing.T) {
}
func TestDetails_NoNotes(t *testing.T) {
t.Run("no notes", func(t *testing.T) {
t.Run("NoNotes", func(t *testing.T) {
description := &Details{PhotoID: 123, Notes: ""}
assert.Equal(t, true, description.NoNotes())
assert.False(t, description.HasNotes())
})
t.Run("notes", func(t *testing.T) {
t.Run("Notes", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "test cat dog", Subject: "animals", Artist: "Bender", Notes: "notes", Copyright: "copy"}
assert.Equal(t, false, description.NoNotes())
@@ -76,14 +76,14 @@ func TestDetails_NoNotes(t *testing.T) {
}
func TestDetails_NoArtist(t *testing.T) {
t.Run("no artist", func(t *testing.T) {
t.Run("NoArtist", func(t *testing.T) {
description := &Details{PhotoID: 123, Artist: ""}
assert.Equal(t, true, description.NoArtist())
assert.False(t, description.HasArtist())
})
t.Run("artist", func(t *testing.T) {
t.Run("Artist", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "test cat dog", Subject: "animals", Artist: "Bender", Notes: "notes", Copyright: "copy"}
assert.Equal(t, false, description.NoArtist())
@@ -92,13 +92,13 @@ func TestDetails_NoArtist(t *testing.T) {
}
func TestDetails_NoCopyright(t *testing.T) {
t.Run("no copyright", func(t *testing.T) {
t.Run("NoCopyright", func(t *testing.T) {
description := &Details{PhotoID: 123, Copyright: ""}
assert.Equal(t, true, description.NoCopyright())
assert.False(t, description.HasCopyright())
})
t.Run("copyright", func(t *testing.T) {
t.Run("Copyright", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "test cat dog", Subject: "animals", Artist: "Bender", Notes: "notes", Copyright: "copy"}
assert.Equal(t, false, description.NoCopyright())
@@ -107,13 +107,13 @@ func TestDetails_NoCopyright(t *testing.T) {
}
func TestDetails_NoLicense(t *testing.T) {
t.Run("no license", func(t *testing.T) {
t.Run("NoLicense", func(t *testing.T) {
description := &Details{PhotoID: 123, License: ""}
assert.Equal(t, true, description.NoLicense())
assert.False(t, description.HasLicense())
})
t.Run("license", func(t *testing.T) {
t.Run("License", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "test cat dog", Subject: "animals", Artist: "Bender", Notes: "notes", License: "copy"}
assert.Equal(t, false, description.NoLicense())
@@ -122,7 +122,7 @@ func TestDetails_NoLicense(t *testing.T) {
}
func TestNewDetails(t *testing.T) {
t.Run("add to photo", func(t *testing.T) {
t.Run("AddToPhoto", func(t *testing.T) {
p := NewPhoto(true)
assert.Equal(t, UnknownTitle, p.PhotoTitle)
@@ -184,28 +184,28 @@ func TestDetails_Save(t *testing.T) {
}
func TestDetails_SetKeywords(t *testing.T) {
t.Run("no keywords", func(t *testing.T) {
t.Run("NoKeywords", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: ""}
assert.False(t, description.HasKeywords())
description.SetKeywords("", "manual")
assert.False(t, description.HasKeywords())
})
t.Run("new keywords have no priority", func(t *testing.T) {
t.Run("NewKeywordsHaveNoPriority", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "cat, brown", KeywordsSrc: SrcManual}
assert.Equal(t, "cat, brown", description.Keywords)
description.SetKeywords("dog", SrcMeta)
assert.Equal(t, "cat, brown", description.Keywords)
})
t.Run("new keywords set - merge", func(t *testing.T) {
t.Run("NewKeywordsSetMerge", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "cat, brown", KeywordsSrc: SrcMeta}
assert.Equal(t, "cat, brown", description.Keywords)
description.SetKeywords("dog", SrcMeta)
assert.Equal(t, "brown, cat, dog", description.Keywords)
})
t.Run("new keywords overwrite", func(t *testing.T) {
t.Run("NewKeywordsOverwrite", func(t *testing.T) {
description := &Details{PhotoID: 123, Keywords: "cat, brown", KeywordsSrc: SrcMeta}
assert.Equal(t, "cat, brown", description.Keywords)
@@ -215,21 +215,21 @@ func TestDetails_SetKeywords(t *testing.T) {
}
func TestDetails_SetSubject(t *testing.T) {
t.Run("no subject", func(t *testing.T) {
t.Run("NoSubject", func(t *testing.T) {
description := &Details{PhotoID: 123, Subject: ""}
assert.False(t, description.HasSubject())
description.SetSubject("", "manual")
assert.False(t, description.HasSubject())
})
t.Run("new subject has no priority", func(t *testing.T) {
t.Run("NewSubjectHasNoPriority", func(t *testing.T) {
description := &Details{PhotoID: 123, Subject: "My cat", SubjectSrc: SrcManual}
assert.Equal(t, "My cat", description.Subject)
description.SetSubject("My dog", SrcMeta)
assert.Equal(t, "My cat", description.Subject)
})
t.Run("new subject set", func(t *testing.T) {
t.Run("NewSubjectSet", func(t *testing.T) {
description := &Details{PhotoID: 123, Subject: "My cat", SubjectSrc: SrcMeta}
assert.Equal(t, "My cat", description.Subject)
@@ -239,21 +239,21 @@ func TestDetails_SetSubject(t *testing.T) {
}
func TestDetails_SetNotes(t *testing.T) {
t.Run("no notes", func(t *testing.T) {
t.Run("NoNotes", func(t *testing.T) {
description := &Details{PhotoID: 123, Notes: ""}
assert.False(t, description.HasNotes())
description.SetNotes("", "manual")
assert.False(t, description.HasNotes())
})
t.Run("new notes has no priority", func(t *testing.T) {
t.Run("NewNotesHasNoPriority", func(t *testing.T) {
description := &Details{PhotoID: 123, Notes: "My old notes", NotesSrc: SrcManual}
assert.Equal(t, "My old notes", description.Notes)
description.SetNotes("My new notes", SrcAuto)
assert.Equal(t, "My old notes", description.Notes)
})
t.Run("new notes set", func(t *testing.T) {
t.Run("NewNotesSet", func(t *testing.T) {
description := &Details{PhotoID: 123, Notes: "My old notes", NotesSrc: SrcMeta}
assert.Equal(t, "My old notes", description.Notes)
@@ -263,21 +263,21 @@ func TestDetails_SetNotes(t *testing.T) {
}
func TestDetails_SetArtist(t *testing.T) {
t.Run("no artist", func(t *testing.T) {
t.Run("NoArtist", func(t *testing.T) {
description := &Details{PhotoID: 123, Artist: ""}
assert.False(t, description.HasArtist())
description.SetArtist("", "manual")
assert.False(t, description.HasArtist())
})
t.Run("new artist has no priority", func(t *testing.T) {
t.Run("NewArtistHasNoPriority", func(t *testing.T) {
description := &Details{PhotoID: 123, Artist: "Hans", ArtistSrc: SrcManual}
assert.Equal(t, "Hans", description.Artist)
description.SetArtist("Maria", SrcAuto)
assert.Equal(t, "Hans", description.Artist)
})
t.Run("new artist set", func(t *testing.T) {
t.Run("NewArtistSet", func(t *testing.T) {
description := &Details{PhotoID: 123, Artist: "Hans", ArtistSrc: SrcMeta}
assert.Equal(t, "Hans", description.Artist)
@@ -287,21 +287,21 @@ func TestDetails_SetArtist(t *testing.T) {
}
func TestDetails_SetCopyright(t *testing.T) {
t.Run("no copyright", func(t *testing.T) {
t.Run("NoCopyright", func(t *testing.T) {
description := &Details{PhotoID: 123, Copyright: ""}
assert.False(t, description.HasCopyright())
description.SetCopyright("", "manual")
assert.False(t, description.HasCopyright())
})
t.Run("new copyright has no priority", func(t *testing.T) {
t.Run("NewCopyrightHasNoPriority", func(t *testing.T) {
description := &Details{PhotoID: 123, Copyright: "2018", CopyrightSrc: SrcManual}
assert.Equal(t, "2018", description.Copyright)
description.SetCopyright("3000", SrcAuto)
assert.Equal(t, "2018", description.Copyright)
})
t.Run("new copyright set", func(t *testing.T) {
t.Run("NewCopyrightSet", func(t *testing.T) {
description := &Details{PhotoID: 123, Copyright: "2018", CopyrightSrc: SrcMeta}
assert.Equal(t, "2018", description.Copyright)
@@ -311,21 +311,21 @@ func TestDetails_SetCopyright(t *testing.T) {
}
func TestDetails_SetLicense(t *testing.T) {
t.Run("no license", func(t *testing.T) {
t.Run("NoLicense", func(t *testing.T) {
description := &Details{PhotoID: 123, License: ""}
assert.False(t, description.HasLicense())
description.SetLicense("", "manual")
assert.False(t, description.HasLicense())
})
t.Run("new license has no priority", func(t *testing.T) {
t.Run("NewLicenseHasNoPriority", func(t *testing.T) {
description := &Details{PhotoID: 123, License: "old", LicenseSrc: SrcManual}
assert.Equal(t, "old", description.License)
description.SetLicense("new", SrcAuto)
assert.Equal(t, "old", description.License)
})
t.Run("new license set", func(t *testing.T) {
t.Run("NewLicenseSet", func(t *testing.T) {
description := &Details{PhotoID: 123, License: "old", LicenseSrc: SrcMeta}
assert.Equal(t, "old", description.License)

View File

@@ -39,7 +39,7 @@ func TestAddDuplicate(t *testing.T) {
t.Fatalf("mod time should be %d", time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix())
}
})
t.Run("error filename empty", func(t *testing.T) {
t.Run("ErrorFilenameEmpty", func(t *testing.T) {
err := AddDuplicate(
"",
"",
@@ -52,7 +52,7 @@ func TestAddDuplicate(t *testing.T) {
t.Fatal("error expected")
}
})
t.Run("error filehash empty", func(t *testing.T) {
t.Run("ErrorFilehashEmpty", func(t *testing.T) {
err := AddDuplicate(
"foobar.jpg",
"",
@@ -65,7 +65,7 @@ func TestAddDuplicate(t *testing.T) {
t.Fatal("error expected")
}
})
t.Run("error mod time empty", func(t *testing.T) {
t.Run("ErrorModTimeEmpty", func(t *testing.T) {
err := AddDuplicate(
"foobar.jpg",
"",
@@ -78,7 +78,7 @@ func TestAddDuplicate(t *testing.T) {
t.Fatal("error expected")
}
})
t.Run("error fileRoot empty", func(t *testing.T) {
t.Run("ErrorFileRootEmpty", func(t *testing.T) {
err := AddDuplicate(
"foobar.jpg",
"",
@@ -94,28 +94,28 @@ func TestAddDuplicate(t *testing.T) {
}
func TestCreateDuplicate(t *testing.T) {
t.Run("error mod time 0", func(t *testing.T) {
t.Run("ErrorModTimeZero", func(t *testing.T) {
duplicate := &Duplicate{FileName: "foobar.jpg", FileHash: "12345tghy", FileRoot: RootOriginals, ModTime: 0}
err := duplicate.Create()
if err == nil {
t.Fatal("error expected")
}
})
t.Run("error filename empty", func(t *testing.T) {
t.Run("ErrorFilenameEmpty", func(t *testing.T) {
duplicate := &Duplicate{FileName: "", FileHash: "12345tghy", FileRoot: RootOriginals, ModTime: time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix()}
err := duplicate.Create()
if err == nil {
t.Fatal("error expected")
}
})
t.Run("error filehash empty", func(t *testing.T) {
t.Run("ErrorFilehashEmpty", func(t *testing.T) {
duplicate := &Duplicate{FileName: "foobar.jpg", FileHash: "", FileRoot: RootOriginals, ModTime: time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix()}
err := duplicate.Create()
if err == nil {
t.Fatal("error expected")
}
})
t.Run("error fileroot empty", func(t *testing.T) {
t.Run("ErrorFilerootEmpty", func(t *testing.T) {
duplicate := &Duplicate{FileName: "foobar.jpg", FileHash: "jhg678", FileRoot: "", ModTime: time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix()}
err := duplicate.Create()
if err == nil {
@@ -125,28 +125,28 @@ func TestCreateDuplicate(t *testing.T) {
}
func TestSaveDuplicate(t *testing.T) {
t.Run("error mod time 0", func(t *testing.T) {
t.Run("ErrorModTimeZero", func(t *testing.T) {
duplicate := &Duplicate{FileName: "foobar.jpg", FileHash: "12345tghy", FileRoot: RootOriginals, ModTime: 0}
err := duplicate.Save()
if err == nil {
t.Fatal("error expected")
}
})
t.Run("error filename empty", func(t *testing.T) {
t.Run("ErrorFilenameEmpty", func(t *testing.T) {
duplicate := &Duplicate{FileName: "", FileHash: "12345tghy", FileRoot: RootOriginals, ModTime: time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix()}
err := duplicate.Save()
if err == nil {
t.Fatal("error expected")
}
})
t.Run("error filehash empty", func(t *testing.T) {
t.Run("ErrorFilehashEmpty", func(t *testing.T) {
duplicate := &Duplicate{FileName: "foobar.jpg", FileHash: "", FileRoot: RootOriginals, ModTime: time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix()}
err := duplicate.Save()
if err == nil {
t.Fatal("error expected")
}
})
t.Run("error fileroot empty", func(t *testing.T) {
t.Run("ErrorFilerootEmpty", func(t *testing.T) {
duplicate := &Duplicate{FileName: "foobar.jpg", FileHash: "jhg678", FileRoot: "", ModTime: time.Date(2019, 3, 6, 2, 6, 51, 0, time.UTC).Unix()}
err := duplicate.Save()
if err == nil {
@@ -191,10 +191,10 @@ func TestDuplicate_Purge(t *testing.T) {
}
func TestPurgeDuplicate(t *testing.T) {
t.Run("empty filename", func(t *testing.T) {
t.Run("EmptyFilename", func(t *testing.T) {
assert.Error(t, PurgeDuplicate("", RootOriginals))
})
t.Run("empty fileroot", func(t *testing.T) {
t.Run("EmptyFileroot", func(t *testing.T) {
assert.Error(t, PurgeDuplicate("test.jpg", ""))
})
}

View File

@@ -51,14 +51,14 @@ func TestNow(t *testing.T) {
t.Fatal("timestamp zone must be GMT")
}
})
t.Run("Etc/GMT", func(t *testing.T) {
t.Run("EtcGmt", func(t *testing.T) {
if location, err := time.LoadLocation("Etc/GMT"); err != nil {
t.Error(err)
} else if Now().In(location).Location().String() != "Etc/GMT" {
t.Fatal("timestamp zone must be Etc/GMT")
}
})
t.Run("Etc/GMT+6", func(t *testing.T) {
t.Run("EtcGmtSix", func(t *testing.T) {
if location, err := time.LoadLocation("Etc/GMT+6"); err != nil {
t.Error(err)
} else if Now().In(location).Location().String() != "Etc/GMT+6" {

View File

@@ -7,13 +7,13 @@ import (
)
func TestFaceMap_Get(t *testing.T) {
t.Run("get existing face", func(t *testing.T) {
t.Run("GetExistingFace", func(t *testing.T) {
r := FaceFixtures.Get("jane-doe")
assert.Equal(t, "js6sg6b1h1njaaab", r.SubjUID)
assert.Equal(t, "VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG7", r.ID)
assert.IsType(t, Face{}, r)
})
t.Run("get not existing location", func(t *testing.T) {
t.Run("GetNotExistingLocation", func(t *testing.T) {
r := FaceFixtures.Get("xxx")
assert.Equal(t, UnknownID, r.ID)
assert.IsType(t, Face{}, r)
@@ -21,13 +21,13 @@ func TestFaceMap_Get(t *testing.T) {
}
func TestFaceMap_Pointer(t *testing.T) {
t.Run("get existing face", func(t *testing.T) {
t.Run("GetExistingFace", func(t *testing.T) {
r := FaceFixtures.Pointer("jane-doe")
assert.Equal(t, "js6sg6b1h1njaaab", r.SubjUID)
assert.Equal(t, "VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG7", r.ID)
assert.IsType(t, &Face{}, r)
})
t.Run("get not existing location", func(t *testing.T) {
t.Run("GetNotExistingLocation", func(t *testing.T) {
r := FaceFixtures.Pointer("xxx")
assert.Equal(t, UnknownID, r.ID)
assert.IsType(t, &Face{}, r)

View File

@@ -15,7 +15,7 @@ func TestFace_TableName(t *testing.T) {
}
func TestFace_Match(t *testing.T) {
t.Run("1000003-4", func(t *testing.T) {
t.Run("Num1000003Four", func(t *testing.T) {
m := FaceFixtures.Get("joe-biden")
match, dist := m.Match(MarkerFixtures.Pointer("1000003-4").Embeddings())
@@ -23,7 +23,7 @@ func TestFace_Match(t *testing.T) {
assert.Greater(t, dist, 1.31)
assert.Less(t, dist, 1.32)
})
t.Run("1000003-6", func(t *testing.T) {
t.Run("Num1000003Six", func(t *testing.T) {
m := FaceFixtures.Get("joe-biden")
match, dist := m.Match(MarkerFixtures.Pointer("1000003-6").Embeddings())
@@ -31,21 +31,21 @@ func TestFace_Match(t *testing.T) {
assert.Greater(t, dist, 1.27)
assert.Less(t, dist, 1.28)
})
t.Run("len(embeddings) == 0", func(t *testing.T) {
t.Run("LenEmbeddingsEqualZero", func(t *testing.T) {
m := FaceFixtures.Get("joe-biden")
match, dist := m.Match(face.Embeddings{})
assert.False(t, match)
assert.Equal(t, dist, float64(-1))
})
t.Run("len(efacEmbeddings) == 0", func(t *testing.T) {
t.Run("LenEfacEmbeddingsEqualZero", func(t *testing.T) {
m := NewFace("12345", SrcAuto, face.Embeddings{})
match, dist := m.Match(MarkerFixtures.Pointer("1000003-6").Embeddings())
assert.False(t, match)
assert.Equal(t, dist, float64(-1))
})
t.Run("jane doe- no match", func(t *testing.T) {
t.Run("JaneDoeNoMatch", func(t *testing.T) {
m := FaceFixtures.Get("jane-doe")
match, _ := m.Match(MarkerFixtures.Pointer("1000003-5").Embeddings())
@@ -54,7 +54,7 @@ func TestFace_Match(t *testing.T) {
}
func TestFace_ResolveCollision(t *testing.T) {
t.Run("collision", func(t *testing.T) {
t.Run("Collision", func(t *testing.T) {
m := FaceFixtures.Get("joe-biden")
assert.Zero(t, m.Collisions)
@@ -86,7 +86,7 @@ func TestFace_ResolveCollision(t *testing.T) {
assert.Greater(t, m.CollisionRadius, 1.1)
assert.Less(t, m.CollisionRadius, 1.272)
})
t.Run("subject id empty", func(t *testing.T) {
t.Run("SubjectIdEmpty", func(t *testing.T) {
m := NewFace("", SrcAuto, face.KidsEmbeddings)
if reported, err := m.ResolveCollision(MarkerFixtures.Pointer("1000003-4").Embeddings()); err != nil {
t.Fatal(err)
@@ -94,7 +94,7 @@ func TestFace_ResolveCollision(t *testing.T) {
assert.False(t, reported)
}
})
t.Run("invalid face id", func(t *testing.T) {
t.Run("InvalidFaceId", func(t *testing.T) {
m := NewFace("123", SrcAuto, face.Embeddings{})
m.ID = ""
if reported, err := m.ResolveCollision(MarkerFixtures.Pointer("1000003-4").Embeddings()); err == nil {
@@ -104,7 +104,7 @@ func TestFace_ResolveCollision(t *testing.T) {
assert.Equal(t, "invalid face id", err.Error())
}
})
t.Run("embedding empty", func(t *testing.T) {
t.Run("EmbeddingEmpty", func(t *testing.T) {
m := NewFace("123", SrcAuto, face.Embeddings{})
m.EmbeddingJSON = []byte("")
m.ID = "foo"
@@ -140,7 +140,7 @@ func TestNewFace(t *testing.T) {
}
func TestFace_MatchId(t *testing.T) {
t.Run("A123-B456", func(t *testing.T) {
t.Run("ANum123BNum456", func(t *testing.T) {
f1 := Face{ID: "A123"}
f2 := Face{ID: "B456"}
f3 := Face{ID: ""}
@@ -183,13 +183,13 @@ func TestFace_Embedding(t *testing.T) {
assert.Equal(t, 0.10730543085474682, m.Embedding()[0])
})
t.Run("empty embedding", func(t *testing.T) {
t.Run("EmptyEmbedding", func(t *testing.T) {
m := NewFace("12345", SrcAuto, face.Embeddings{})
m.EmbeddingJSON = []byte("")
assert.Empty(t, m.Embedding())
})
t.Run("invalid embedding json", func(t *testing.T) {
t.Run("InvalidEmbeddingJson", func(t *testing.T) {
m := NewFace("12345", SrcAuto, face.Embeddings{})
m.EmbeddingJSON = []byte("[false]")
@@ -263,12 +263,12 @@ func TestFace_RefreshPhotos(t *testing.T) {
}
func TestFirstOrCreateFace(t *testing.T) {
t.Run("create new face", func(t *testing.T) {
t.Run("CreateNewFace", func(t *testing.T) {
m := NewFace("12345unique", SrcAuto, face.RandomEmbeddings(1, face.RegularFace))
r := FirstOrCreateFace(m)
assert.Equal(t, "12345unique", r.SubjUID)
})
t.Run("return existing entity", func(t *testing.T) {
t.Run("ReturnExistingEntity", func(t *testing.T) {
m := FaceFixtures.Pointer("joe-biden")
r := FirstOrCreateFace(m)
assert.Equal(t, "js6sg6b2h8njw0sx", r.SubjUID)
@@ -277,11 +277,11 @@ func TestFirstOrCreateFace(t *testing.T) {
}
func TestFindFace(t *testing.T) {
t.Run("existing face", func(t *testing.T) {
t.Run("ExistingFace", func(t *testing.T) {
assert.NotNil(t, FindFace("VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG7"))
assert.Equal(t, 3, FindFace("VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG7").Samples)
})
t.Run("empty id", func(t *testing.T) {
t.Run("EmptyId", func(t *testing.T) {
assert.Nil(t, FindFace(""))
})
}

View File

@@ -7,13 +7,13 @@ import (
)
func TestFileMap_Get(t *testing.T) {
t.Run("get existing file", func(t *testing.T) {
t.Run("GetExistingFile", func(t *testing.T) {
r := FileFixtures.Get("exampleFileName.jpg")
assert.Equal(t, "fs6sg6bw45bnlqdw", r.FileUID)
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", r.FileName)
assert.IsType(t, File{}, r)
})
t.Run("get not existing file", func(t *testing.T) {
t.Run("GetNotExistingFile", func(t *testing.T) {
r := FileFixtures.Get("TestName")
assert.Equal(t, "TestName", r.FileName)
assert.IsType(t, File{}, r)
@@ -21,13 +21,13 @@ func TestFileMap_Get(t *testing.T) {
}
func TestFileMap_Pointer(t *testing.T) {
t.Run("get existing file", func(t *testing.T) {
t.Run("GetExistingFile", func(t *testing.T) {
r := FileFixtures.Pointer("exampleFileName.jpg")
assert.Equal(t, "fs6sg6bw45bnlqdw", r.FileUID)
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", r.FileName)
assert.IsType(t, &File{}, r)
})
t.Run("get not existing file", func(t *testing.T) {
t.Run("GetNotExistingFile", func(t *testing.T) {
r := FileFixtures.Pointer("TestName")
assert.Equal(t, "TestName", r.FileName)
assert.IsType(t, &File{}, r)

View File

@@ -7,13 +7,13 @@ import (
)
func TestFileShareMap_Get(t *testing.T) {
t.Run("get existing fileshare", func(t *testing.T) {
t.Run("GetExistingFileshare", func(t *testing.T) {
r := FileShareFixtures.Get("FileShare1", 0, 0, "")
assert.Equal(t, uint(1000000), r.ServiceID)
assert.Equal(t, "/20100729-015747-Urlaub-2010.jpg", r.RemoteName)
assert.IsType(t, FileShare{}, r)
})
t.Run("get not existing fileshare", func(t *testing.T) {
t.Run("GetNotExistingFileshare", func(t *testing.T) {
r := FileShareFixtures.Get("FileShareXXX", 123, 888, "new remote name")
assert.Equal(t, uint(888), r.ServiceID)
assert.Equal(t, "new remote name", r.RemoteName)
@@ -22,13 +22,13 @@ func TestFileShareMap_Get(t *testing.T) {
}
func TestFileShareMap_Pointer(t *testing.T) {
t.Run("get existing fileshare pointer", func(t *testing.T) {
t.Run("GetExistingFilesharePointer", func(t *testing.T) {
r := FileShareFixtures.Pointer("FileShare1", 0, 0, "")
assert.Equal(t, uint(1000000), r.ServiceID)
assert.Equal(t, "/20100729-015747-Urlaub-2010.jpg", r.RemoteName)
assert.IsType(t, &FileShare{}, r)
})
t.Run("get not existing fileshare pointer", func(t *testing.T) {
t.Run("GetNotExistingFilesharePointer", func(t *testing.T) {
r := FileShareFixtures.Pointer("FileShareYYY", 456, 889, "new remote name for pointer")
assert.Equal(t, uint(889), r.ServiceID)
assert.Equal(t, "new remote name for pointer", r.RemoteName)

View File

@@ -21,7 +21,7 @@ func TestNewFileShare(t *testing.T) {
}
func TestFirstOrCreateFileShare(t *testing.T) {
t.Run("not yet existing", func(t *testing.T) {
t.Run("NotYetExisting", func(t *testing.T) {
fileShare := &FileShare{FileID: 123, ServiceID: 888, RemoteName: "test888"}
result := FirstOrCreateFileShare(fileShare)
@@ -37,7 +37,7 @@ func TestFirstOrCreateFileShare(t *testing.T) {
t.Errorf("ServiceID should be the same: %d %d", result.ServiceID, fileShare.ServiceID)
}
})
t.Run("existing", func(t *testing.T) {
t.Run("Existing", func(t *testing.T) {
fileShare := NewFileShare(778, 999, "NameForRemote")
result := FirstOrCreateFileShare(fileShare)

View File

@@ -7,13 +7,13 @@ import (
)
func TestFileSyncMap_Get(t *testing.T) {
t.Run("get existing filesync", func(t *testing.T) {
t.Run("GetExistingFilesync", func(t *testing.T) {
r := FileSyncFixtures.Get("FileSync1", 0, "")
assert.Equal(t, uint(1000000), r.ServiceID)
assert.Equal(t, "/20200706-092527-Landscape-München-2020.jpg", r.RemoteName)
assert.IsType(t, FileSync{}, r)
})
t.Run("get not existing filesync", func(t *testing.T) {
t.Run("GetNotExistingFilesync", func(t *testing.T) {
r := FileSyncFixtures.Get("FileSyncXXX", 123, "new remote name for sync")
assert.Equal(t, uint(123), r.ServiceID)
assert.Equal(t, "new remote name for sync", r.RemoteName)
@@ -22,13 +22,13 @@ func TestFileSyncMap_Get(t *testing.T) {
}
func TestFileSyncMap_Pointer(t *testing.T) {
t.Run("get existing filesync pointer", func(t *testing.T) {
t.Run("GetExistingFilesyncPointer", func(t *testing.T) {
r := FileSyncFixtures.Pointer("FileSync1", 0, "")
assert.Equal(t, uint(1000000), r.ServiceID)
assert.Equal(t, "/20200706-092527-Landscape-München-2020.jpg", r.RemoteName)
assert.IsType(t, &FileSync{}, r)
})
t.Run("get not existing filesync pointer", func(t *testing.T) {
t.Run("GetNotExistingFilesyncPointer", func(t *testing.T) {
r := FileSyncFixtures.Pointer("FileSyncYYY", 456, "new remote name for sync pointer")
assert.Equal(t, uint(456), r.ServiceID)
assert.Equal(t, "new remote name for sync pointer", r.RemoteName)

View File

@@ -20,7 +20,7 @@ func TestNewFileSync(t *testing.T) {
}
func TestFirstOrCreateFileSync(t *testing.T) {
t.Run("not yet existing", func(t *testing.T) {
t.Run("NotYetExisting", func(t *testing.T) {
fileSync := &FileSync{ServiceID: 123, FileID: 888, RemoteName: "test123"}
result := FirstOrCreateFileSync(fileSync)
@@ -36,7 +36,7 @@ func TestFirstOrCreateFileSync(t *testing.T) {
t.Errorf("ServiceID should be the same: %d %d", result.ServiceID, fileSync.ServiceID)
}
})
t.Run("existing", func(t *testing.T) {
t.Run("Existing", func(t *testing.T) {
fileSync := NewFileSync(778, "NameForRemote")
result := FirstOrCreateFileSync(fileSync)

View File

@@ -39,13 +39,13 @@ func TestFile_RegenerateIndex(t *testing.T) {
}
func TestFirstFileByHash(t *testing.T) {
t.Run("not existing file", func(t *testing.T) {
t.Run("NotExistingFile", func(t *testing.T) {
f, err := FirstFileByHash("xxx")
assert.EqualError(t, err, "record not found")
assert.Equal(t, uint(0), f.ID)
})
t.Run("existing file", func(t *testing.T) {
t.Run("ExistingFile", func(t *testing.T) {
f, err := FirstFileByHash("2cad9168fa6acc5c5c2965ddf6ec465ca42fd818")
if err != nil {
t.Fatal(err)
@@ -117,22 +117,22 @@ func TestFile_ShareFileName(t *testing.T) {
func TestFile_Changed(t *testing.T) {
var deletedAt = time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC)
t.Run("different modified times", func(t *testing.T) {
t.Run("DifferentModifiedTimes", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix()}
d := time.Date(2020, 01, 15, 0, 0, 0, 0, time.UTC)
assert.Equal(t, true, file.Changed(500, d))
})
t.Run("different sizes", func(t *testing.T) {
t.Run("DifferentSizes", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSize: 600, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix()}
d := time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC)
assert.Equal(t, true, file.Changed(500, d))
})
t.Run("no change", func(t *testing.T) {
t.Run("NoChange", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix()}
d := time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC)
assert.Equal(t, false, file.Changed(500, d))
})
t.Run("deleted", func(t *testing.T) {
t.Run("Deleted", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix(), DeletedAt: &deletedAt}
d := time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC)
assert.Equal(t, false, file.Changed(500, d))
@@ -142,27 +142,27 @@ func TestFile_Changed(t *testing.T) {
func TestFile_Missing(t *testing.T) {
var deletedAt = time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC)
t.Run("deleted", func(t *testing.T) {
t.Run("Deleted", func(t *testing.T) {
file := &File{FileMissing: false, Photo: nil, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix(), DeletedAt: &deletedAt}
assert.Equal(t, true, file.Missing())
})
t.Run("missing", func(t *testing.T) {
t.Run("Missing", func(t *testing.T) {
file := &File{FileMissing: true, Photo: nil, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix(), DeletedAt: nil}
assert.Equal(t, true, file.Missing())
})
t.Run("not_missing", func(t *testing.T) {
t.Run("NotMissing", func(t *testing.T) {
file := &File{FileMissing: false, Photo: nil, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix(), DeletedAt: nil}
assert.Equal(t, false, file.Missing())
})
}
func TestFile_Create(t *testing.T) {
t.Run("photo id == 0", func(t *testing.T) {
t.Run("PhotoIdEqualZero", func(t *testing.T) {
file := File{PhotoID: 0}
assert.Error(t, file.Create())
})
t.Run("file already exists", func(t *testing.T) {
t.Run("FileAlreadyExists", func(t *testing.T) {
file := &File{PhotoID: 123, FileType: "jpg", FileSize: 500, ModTime: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC).Unix()}
assert.Nil(t, file.Create())
assert.Error(t, file.Create())
@@ -202,18 +202,18 @@ func TestFile_Found(t *testing.T) {
}
func TestFile_AllFilesMissing(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
file := FileFixtures.Get("missing.jpg")
assert.True(t, file.AllFilesMissing())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
file := FileFixtures.Get("Quality1FavoriteTrue.jpg")
assert.False(t, file.AllFilesMissing())
})
}
func TestFile_Save(t *testing.T) {
t.Run("save without photo", func(t *testing.T) {
t.Run("SaveWithoutPhoto", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", PhotoUID: "123", FileUID: "123"}
err := file.Save()
@@ -290,7 +290,7 @@ func TestFile_Update(t *testing.T) {
}
func TestFile_Links(t *testing.T) {
t.Run("result", func(t *testing.T) {
t.Run("Result", func(t *testing.T) {
file := FileFixturesExampleBridge
links := file.Links()
if len(links) == 0 {
@@ -302,64 +302,64 @@ func TestFile_Links(t *testing.T) {
}
func TestFile_NoJpeg(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
file := &File{Photo: nil, FileType: "xmp", FileSize: 500}
assert.True(t, file.NoJpeg())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSize: 500}
assert.False(t, file.NoJpeg())
})
}
func TestFile_NoPng(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
file := &File{Photo: nil, FileType: "xmp", FileSize: 500}
assert.True(t, file.NoPng())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
file := &File{Photo: nil, FileType: "png", FileSize: 500}
assert.False(t, file.NoPng())
})
}
func TestFile_Type(t *testing.T) {
t.Run("xmp", func(t *testing.T) {
t.Run("Xmp", func(t *testing.T) {
file := &File{Photo: nil, FileType: "xmp", FileSize: 500}
assert.Equal(t, fs.SidecarXMP, file.Type())
})
t.Run("png", func(t *testing.T) {
t.Run("Png", func(t *testing.T) {
file := &File{Photo: nil, FileType: "png", FileSize: 500}
assert.Equal(t, fs.ImagePng, file.Type())
})
}
func TestFile_Panorama(t *testing.T) {
t.Run("3000", func(t *testing.T) {
t.Run("Num3000", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 3000, FileHeight: 1000}
assert.True(t, file.Panorama())
})
t.Run("1999", func(t *testing.T) {
t.Run("Num1999", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 1910, FileHeight: 1000}
assert.True(t, file.Panorama())
})
t.Run("2000", func(t *testing.T) {
t.Run("Num2000", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 2000, FileHeight: 1000}
assert.True(t, file.Panorama())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 1500, FileHeight: 1000}
assert.False(t, file.Panorama())
})
t.Run("equirectangular", func(t *testing.T) {
t.Run("Equirectangular", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 1500, FileHeight: 1000, FileProjection: projection.Equirectangular.String()}
assert.True(t, file.Panorama())
})
t.Run("transverse-cylindrical", func(t *testing.T) {
t.Run("TransverseCylindrical", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 1500, FileHeight: 1000, FileProjection: projection.TransverseCylindrical.String()}
assert.True(t, file.Panorama())
})
t.Run("sidecar", func(t *testing.T) {
t.Run("Sidecar", func(t *testing.T) {
file := &File{Photo: nil, FileType: "xmp", FileSidecar: true, FileWidth: 3000, FileHeight: 1000}
assert.False(t, file.Panorama())
})
@@ -406,7 +406,7 @@ func TestFile_SetProjection(t *testing.T) {
}
func TestFile_Delete(t *testing.T) {
t.Run("permanently", func(t *testing.T) {
t.Run("Permanently", func(t *testing.T) {
file := &File{FileType: "jpg", FileSize: 500, FileName: "ToBePermanentlyDeleted", FileRoot: "", PhotoID: 5678}
err := file.Save()
@@ -420,7 +420,7 @@ func TestFile_Delete(t *testing.T) {
assert.Nil(t, err2)
})
t.Run("not permanently", func(t *testing.T) {
t.Run("NotPermanently", func(t *testing.T) {
file := &File{FileType: "jpg", FileSize: 500, FileName: "ToBeDeleted", FileRoot: "", PhotoID: 5678}
err := file.Save()
@@ -445,7 +445,7 @@ func TestPrimaryFile(t *testing.T) {
}
func TestFile_OriginalBase(t *testing.T) {
t.Run("original name empty, filename empty", func(t *testing.T) {
t.Run("OriginalNameEmptyFilenameEmpty", func(t *testing.T) {
photo := &Photo{TakenAtLocal: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC), PhotoTitle: "Berlin / Morning Mood"}
file := &File{Photo: photo, FileType: "jpg", FileUID: "foobar345678765", FileHash: "e98eb86480a72bd585d228a709f0622f90e86cbc", OriginalName: "", FileName: ""}
@@ -459,7 +459,7 @@ func TestFile_OriginalBase(t *testing.T) {
assert.Contains(t, filename2, "(1)")
assert.Contains(t, filename2, fs.ExtJpeg)
})
t.Run("original name empty", func(t *testing.T) {
t.Run("OriginalNameEmpty", func(t *testing.T) {
photo := &Photo{TakenAtLocal: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC), PhotoTitle: "Berlin / Morning Mood"}
file := &File{Photo: photo, FileType: "jpg", FileUID: "foobar345678765", FileHash: "e98eb86480a72bd585d228a709f0622f90e86cbc", OriginalName: "", FileName: "sonnenaufgang.jpg"}
@@ -473,7 +473,7 @@ func TestFile_OriginalBase(t *testing.T) {
assert.Contains(t, filename2, "(1)")
assert.Contains(t, filename2, fs.ExtJpeg)
})
t.Run("original name not empty", func(t *testing.T) {
t.Run("OriginalNameNotEmpty", func(t *testing.T) {
photo := &Photo{TakenAtLocal: time.Date(2019, 01, 15, 0, 0, 0, 0, time.UTC), PhotoTitle: "Berlin / Morning Mood"}
file := &File{Photo: photo, FileType: "jpg", FileUID: "foobar345678765", FileHash: "e98eb86480a72bd585d228a709f0622f90e86cbc", OriginalName: "Sonnenaufgang.jpg", FileName: "123.jpg"}
@@ -520,7 +520,7 @@ func TestFile_Undelete(t *testing.T) {
}
assert.Equal(t, false, file.FileMissing)
})
t.Run("file not missing", func(t *testing.T) {
t.Run("FileNotMissing", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSize: 500}
assert.Equal(t, false, file.FileMissing)
err := file.Undelete()
@@ -625,7 +625,7 @@ func TestFile_Rename(t *testing.T) {
}
func TestFile_SubjectNames(t *testing.T) {
t.Run("Photo27.jpg", func(t *testing.T) {
t.Run("PhotoNum27Jpg", func(t *testing.T) {
m := FileFixtures.Get("Photo27.jpg")
names := m.SubjectNames()
@@ -636,7 +636,7 @@ func TestFile_SubjectNames(t *testing.T) {
assert.Equal(t, "Actress A", names[0])
}
})
t.Run("Video.jpg", func(t *testing.T) {
t.Run("VideoJpg", func(t *testing.T) {
m := FileFixtures.Get("Video.jpg")
names := m.SubjectNames()
@@ -647,7 +647,7 @@ func TestFile_SubjectNames(t *testing.T) {
assert.Equal(t, "Actor A", names[0])
}
})
t.Run("bridge.jpg", func(t *testing.T) {
t.Run("BridgeJpg", func(t *testing.T) {
m := FileFixtures.Get("bridge.jpg")
names := m.SubjectNames()
@@ -661,7 +661,7 @@ func TestFile_SubjectNames(t *testing.T) {
}
func TestFile_UnsavedMarkers(t *testing.T) {
t.Run("bridge2.jpg", func(t *testing.T) {
t.Run("Bridge2Jpg", func(t *testing.T) {
m := FileFixtures.Get("bridge2.jpg")
assert.Equal(t, "fs6sg6bw15bnlqdw", m.FileUID)
assert.False(t, m.UnsavedMarkers())
@@ -687,7 +687,7 @@ func TestFile_UnsavedMarkers(t *testing.T) {
}
func TestFile_ReplaceHash(t *testing.T) {
t.Run("exampleFileName.jpg", func(t *testing.T) {
t.Run("ExampleFileNameJpg", func(t *testing.T) {
m := FileFixtures.Get("exampleFileName.jpg")
if err := m.ReplaceHash(""); err != nil {

View File

@@ -11,7 +11,7 @@ import (
)
func TestNewFolder(t *testing.T) {
t.Run("2020/05", func(t *testing.T) {
t.Run("Num2020Num05", func(t *testing.T) {
folder := NewFolder(RootOriginals, "2020/05", time.Now().UTC())
assert.Equal(t, RootOriginals, folder.Root)
assert.Equal(t, "2020/05", folder.Path)
@@ -27,7 +27,7 @@ func TestNewFolder(t *testing.T) {
assert.Equal(t, 5, folder.FolderMonth)
assert.Equal(t, UnknownID, folder.FolderCountry)
})
t.Run("/2020/05/01/", func(t *testing.T) {
t.Run("Num2020Num05Num01", func(t *testing.T) {
folder := NewFolder(RootOriginals, "/2020/05/01/", time.Now().UTC())
assert.Equal(t, "2020/05/01", folder.Path)
assert.Equal(t, "May 2020", folder.FolderTitle)
@@ -35,7 +35,7 @@ func TestNewFolder(t *testing.T) {
assert.Equal(t, 5, folder.FolderMonth)
assert.Equal(t, UnknownID, folder.FolderCountry)
})
t.Run("/2020/05/23/", func(t *testing.T) {
t.Run("Num2020Num05Num23", func(t *testing.T) {
folder := NewFolder(RootImport, "/2020/05/23/", time.Now().UTC())
assert.Equal(t, "2020/05/23", folder.Path)
assert.Equal(t, "May 23, 2020", folder.FolderTitle)
@@ -43,7 +43,7 @@ func TestNewFolder(t *testing.T) {
assert.Equal(t, 5, folder.FolderMonth)
assert.Equal(t, UnknownID, folder.FolderCountry)
})
t.Run("/2020/05/23/Iceland 2020", func(t *testing.T) {
t.Run("Num2020Num05Num23IcelandNum2020", func(t *testing.T) {
folder := NewFolder(RootOriginals, "/2020/05/23/Iceland 2020", time.Now().UTC())
assert.Equal(t, "2020/05/23/Iceland 2020", folder.Path)
assert.Equal(t, "Iceland 2020", folder.FolderTitle)
@@ -51,7 +51,7 @@ func TestNewFolder(t *testing.T) {
assert.Equal(t, 5, folder.FolderMonth)
assert.Equal(t, "is", folder.FolderCountry)
})
t.Run("/London/2020/05/23", func(t *testing.T) {
t.Run("LondonNum2020Num05Num23", func(t *testing.T) {
folder := NewFolder(RootOriginals, "/London/2020/05/23", time.Now().UTC())
assert.Equal(t, "London/2020/05/23", folder.Path)
assert.Equal(t, "May 23, 2020", folder.FolderTitle)
@@ -115,7 +115,7 @@ func TestFirstOrCreateFolder(t *testing.T) {
}
func TestFolder_SetValuesFromPath(t *testing.T) {
t.Run("/", func(t *testing.T) {
t.Run("Root", func(t *testing.T) {
folder := NewFolder("new", "", time.Now().UTC())
folder.SetValuesFromPath()
assert.Equal(t, "New", folder.FolderTitle)
@@ -123,14 +123,14 @@ func TestFolder_SetValuesFromPath(t *testing.T) {
}
func TestFolder_Slug(t *testing.T) {
t.Run("/", func(t *testing.T) {
t.Run("Root", func(t *testing.T) {
folder := Folder{FolderTitle: "Beautiful beach", Root: "sidecar", Path: "ugly/beach"}
assert.Equal(t, "ugly-beach", folder.Slug())
})
}
func TestFolder_Title(t *testing.T) {
t.Run("/", func(t *testing.T) {
t.Run("Root", func(t *testing.T) {
folder := Folder{FolderTitle: "Beautiful beach"}
assert.Equal(t, "Beautiful beach", folder.Title())
})

View File

@@ -7,13 +7,13 @@ import (
)
func TestKeywordMap_Get(t *testing.T) {
t.Run("get existing keyword", func(t *testing.T) {
t.Run("GetExistingKeyword", func(t *testing.T) {
r := KeywordFixtures.Get("bridge")
assert.Equal(t, uint(1000000), r.ID)
assert.Equal(t, "bridge", r.Keyword)
assert.IsType(t, Keyword{}, r)
})
t.Run("get not existing keyword", func(t *testing.T) {
t.Run("GetNotExistingKeyword", func(t *testing.T) {
r := KeywordFixtures.Get("Fusion")
assert.Equal(t, "fusion", r.Keyword)
assert.IsType(t, Keyword{}, r)
@@ -21,13 +21,13 @@ func TestKeywordMap_Get(t *testing.T) {
}
func TestKeywordMap_Pointer(t *testing.T) {
t.Run("get existing keyword pointer", func(t *testing.T) {
t.Run("GetExistingKeywordPointer", func(t *testing.T) {
r := KeywordFixtures.Pointer("bridge")
assert.Equal(t, uint(1000000), r.ID)
assert.Equal(t, "bridge", r.Keyword)
assert.IsType(t, &Keyword{}, r)
})
t.Run("get not existing keyword pointer", func(t *testing.T) {
t.Run("GetNotExistingKeywordPointer", func(t *testing.T) {
r := KeywordFixtures.Pointer("sweets")
assert.Equal(t, "sweets", r.Keyword)
assert.IsType(t, &Keyword{}, r)

View File

@@ -7,7 +7,7 @@ import (
)
func TestNewKeyword(t *testing.T) {
t.Run("cat", func(t *testing.T) {
t.Run("Cat", func(t *testing.T) {
keyword := NewKeyword("cat")
assert.Equal(t, "cat", keyword.Keyword)
assert.Equal(t, false, keyword.Skip)

View File

@@ -7,13 +7,13 @@ import (
)
func TestLabelMap_Get(t *testing.T) {
t.Run("get existing label", func(t *testing.T) {
t.Run("GetExistingLabel", func(t *testing.T) {
r := LabelFixtures.Get("landscape")
assert.Equal(t, "ls6sg6b1wowuy3c2", r.LabelUID)
assert.Equal(t, "landscape", r.LabelSlug)
assert.IsType(t, Label{}, r)
})
t.Run("get not existing label", func(t *testing.T) {
t.Run("GetNotExistingLabel", func(t *testing.T) {
r := LabelFixtures.Get("monstera")
assert.Equal(t, "monstera", r.LabelSlug)
assert.IsType(t, Label{}, r)
@@ -21,13 +21,13 @@ func TestLabelMap_Get(t *testing.T) {
}
func TestLabelMap_Pointer(t *testing.T) {
t.Run("get existing label pointer", func(t *testing.T) {
t.Run("GetExistingLabelPointer", func(t *testing.T) {
r := LabelFixtures.Pointer("landscape")
assert.Equal(t, "ls6sg6b1wowuy3c2", r.LabelUID)
assert.Equal(t, "landscape", r.LabelSlug)
assert.IsType(t, &Label{}, r)
})
t.Run("get not existing label pointer", func(t *testing.T) {
t.Run("GetNotExistingLabelPointer", func(t *testing.T) {
r := LabelFixtures.Pointer("monstera Leaf")
assert.Equal(t, "monstera-leaf", r.LabelSlug)
assert.IsType(t, &Label{}, r)

View File

@@ -10,13 +10,13 @@ import (
)
func TestNewLabel(t *testing.T) {
t.Run("name Unicorn2000 priority 5", func(t *testing.T) {
t.Run("NameUnicornNum2000PriorityFive", func(t *testing.T) {
label := NewLabel("Unicorn2000", 5)
assert.Equal(t, "Unicorn2000", label.LabelName)
assert.Equal(t, "unicorn2000", label.LabelSlug)
assert.Equal(t, 5, label.LabelPriority)
})
t.Run("name Unknown", func(t *testing.T) {
t.Run("NameUnknown", func(t *testing.T) {
label := NewLabel("", -6)
assert.Equal(t, "Unknown", label.LabelName)
assert.Equal(t, "unknown", label.LabelSlug)
@@ -31,7 +31,7 @@ func TestFlushLabelCache(t *testing.T) {
}
func TestLabel_SetName(t *testing.T) {
t.Run("set name", func(t *testing.T) {
t.Run("SetName", func(t *testing.T) {
entity := LabelFixtures["landscape"]
assert.Equal(t, "Landscape", entity.LabelName)
@@ -44,7 +44,7 @@ func TestLabel_SetName(t *testing.T) {
assert.Equal(t, "landscape", entity.LabelSlug)
assert.Equal(t, "landschaft", entity.CustomSlug)
})
t.Run("new name empty", func(t *testing.T) {
t.Run("NewNameEmpty", func(t *testing.T) {
entity := LabelFixtures["flower"]
assert.Equal(t, "Flower", entity.LabelName)
@@ -77,7 +77,7 @@ func TestFirstOrCreateLabel(t *testing.T) {
}
func TestLabel_UpdateClassify(t *testing.T) {
t.Run("update priority and label slug", func(t *testing.T) {
t.Run("UpdatePriorityAndLabelSlug", func(t *testing.T) {
classifyLabel := &classify.Label{Name: "classify", Uncertainty: 30, Source: "manual", Priority: 5}
result := &Label{LabelName: "label", LabelSlug: "", CustomSlug: "customslug", LabelPriority: 4}
@@ -97,7 +97,7 @@ func TestLabel_UpdateClassify(t *testing.T) {
assert.Equal(t, "classify", result.CustomSlug)
assert.Equal(t, "Classify", result.LabelName)
})
t.Run("update custom slug", func(t *testing.T) {
t.Run("UpdateCustomSlug", func(t *testing.T) {
classifyLabel := &classify.Label{Name: "classify", Uncertainty: 30, Source: "manual", Priority: 5}
result := &Label{LabelName: "label12", LabelSlug: "labelslug", CustomSlug: "", LabelPriority: 5}
@@ -117,7 +117,7 @@ func TestLabel_UpdateClassify(t *testing.T) {
assert.Equal(t, "Classify", result.LabelName)
})
t.Run("update name and Categories", func(t *testing.T) {
t.Run("UpdateNameAndCategories", func(t *testing.T) {
classifyLabel := &classify.Label{Name: "classify", Uncertainty: 30, Source: "manual", Priority: 5, Categories: []string{"flower", "plant"}}
result := &Label{LabelName: "label34", LabelSlug: "labelslug2", CustomSlug: "labelslug2", LabelPriority: 5, LabelCategories: []*Label{LabelFixtures.Pointer("flower")}}
@@ -200,7 +200,7 @@ func TestLabel_Restore(t *testing.T) {
assert.False(t, label.Deleted())
})
t.Run("label not deleted", func(t *testing.T) {
t.Run("LabelNotDeleted", func(t *testing.T) {
label := &Label{DeletedAt: nil, LabelName: "NotDeleted1234"}
if err := label.Restore(); err != nil {

View File

@@ -7,13 +7,13 @@ import (
)
func TestLensMap_Get(t *testing.T) {
t.Run("get existing lens", func(t *testing.T) {
t.Run("GetExistingLens", func(t *testing.T) {
r := LensFixtures.Get("lens-f-380")
assert.Equal(t, uint(1000000), r.ID)
assert.Equal(t, "lens-f-380", r.LensSlug)
assert.IsType(t, Lens{}, r)
})
t.Run("get not existing lens", func(t *testing.T) {
t.Run("GetNotExistingLens", func(t *testing.T) {
r := LensFixtures.Get("Lens 123")
assert.Equal(t, "lens-123", r.LensSlug)
assert.IsType(t, Lens{}, r)
@@ -21,13 +21,13 @@ func TestLensMap_Get(t *testing.T) {
}
func TestLensMap_Pointer(t *testing.T) {
t.Run("get existing lens pointer", func(t *testing.T) {
t.Run("GetExistingLensPointer", func(t *testing.T) {
r := LensFixtures.Pointer("lens-f-380")
assert.Equal(t, uint(1000000), r.ID)
assert.Equal(t, "lens-f-380", r.LensSlug)
assert.IsType(t, &Lens{}, r)
})
t.Run("get not existing lens pointer", func(t *testing.T) {
t.Run("GetNotExistingLensPointer", func(t *testing.T) {
r := LensFixtures.Pointer("Lens new")
assert.Equal(t, "lens-new", r.LensSlug)
assert.IsType(t, &Lens{}, r)

View File

@@ -23,28 +23,28 @@ func TestNewLens(t *testing.T) {
assert.Equal(t, "F500-99", lens.LensModel)
assert.Equal(t, "Canon", lens.LensMake)
})
t.Run("iPhoneXS", func(t *testing.T) {
t.Run("IPhoneXs", func(t *testing.T) {
lens := NewLens("Apple", "iPhone XS back camera 4.25mm f/1.8")
assert.Equal(t, "apple-iphone-xs-4-25mm-f-1-8", lens.LensSlug)
assert.Equal(t, "Apple iPhone XS 4.25mm f/1.8", lens.LensName)
assert.Equal(t, "iPhone XS 4.25mm f/1.8", lens.LensModel)
assert.Equal(t, "Apple", lens.LensMake)
})
t.Run("iPhone12mini", func(t *testing.T) {
t.Run("IPhoneTwelveMini", func(t *testing.T) {
lens := NewLens("Apple", "iPhone 12 mini back dual wide camera 4.2mm f/1.6")
assert.Equal(t, "apple-iphone-12-mini-4-2mm-f-1-6", lens.LensSlug)
assert.Equal(t, "Apple iPhone 12 mini 4.2mm f/1.6", lens.LensName)
assert.Equal(t, "iPhone 12 mini 4.2mm f/1.6", lens.LensModel)
assert.Equal(t, "Apple", lens.LensMake)
})
t.Run("iPhone12UltraWide", func(t *testing.T) {
t.Run("IPhoneTwelveUltraWide", func(t *testing.T) {
lens := NewLens("Apple", "iPhone 12 back dual wide camera 1.55mm f/2.4")
assert.Equal(t, "apple-iphone-12-1-55mm-f-2-4", lens.LensSlug)
assert.Equal(t, "Apple iPhone 12 1.55mm f/2.4", lens.LensName)
assert.Equal(t, "iPhone 12 1.55mm f/2.4", lens.LensModel)
assert.Equal(t, "Apple", lens.LensMake)
})
t.Run("iPhone14ProMax", func(t *testing.T) {
t.Run("IPhoneFourteenProMax", func(t *testing.T) {
lens := NewLens("Apple", "iPhone 14 Pro Max back triple camera 9mm f/2.8")
assert.Equal(t, "apple-iphone-14-pro-max-9mm-f-2-8", lens.LensSlug)
assert.Equal(t, "Apple iPhone 14 Pro Max 9mm f/2.8", lens.LensName)
@@ -66,7 +66,7 @@ func TestLens_String(t *testing.T) {
}
func TestFirstOrCreateLens(t *testing.T) {
t.Run("existing lens", func(t *testing.T) {
t.Run("ExistingLens", func(t *testing.T) {
lens := NewLens("Apple", "iPhone SE")
result := FirstOrCreateLens(lens)
@@ -75,7 +75,7 @@ func TestFirstOrCreateLens(t *testing.T) {
t.Fatal("result should not be nil")
}
})
t.Run("not existing lens", func(t *testing.T) {
t.Run("NotExistingLens", func(t *testing.T) {
lens := &Lens{}
result := FirstOrCreateLens(lens)

View File

@@ -80,11 +80,11 @@ func TestLink_SetPassword(t *testing.T) {
}
func TestLink_InvalidPassword(t *testing.T) {
t.Run("no password", func(t *testing.T) {
t.Run("NoPassword", func(t *testing.T) {
link := Link{LinkUID: "dftjdfkvhjh", HasPassword: false}
assert.False(t, link.InvalidPassword("123"))
})
t.Run("invalid password", func(t *testing.T) {
t.Run("InvalidPassword", func(t *testing.T) {
link := NewLink("dhfjf", false, false)
err := link.SetPassword("123")
@@ -93,7 +93,7 @@ func TestLink_InvalidPassword(t *testing.T) {
}
assert.False(t, link.InvalidPassword("123"))
})
t.Run("valid password", func(t *testing.T) {
t.Run("ValidPassword", func(t *testing.T) {
link := NewLink("dhfjfk", false, false)
err := link.SetPassword("123kkljgfuA")
@@ -105,12 +105,12 @@ func TestLink_InvalidPassword(t *testing.T) {
}
func TestLink_Save(t *testing.T) {
t.Run("invalid share uid", func(t *testing.T) {
t.Run("InvalidShareUid", func(t *testing.T) {
link := NewLink("dhfjfjh", false, false)
assert.Error(t, link.Save())
})
t.Run("empty token", func(t *testing.T) {
t.Run("EmptyToken", func(t *testing.T) {
link := Link{ShareUID: "ls6sg6bffgtredft", LinkToken: ""}
assert.Error(t, link.Save())
@@ -137,11 +137,11 @@ func TestLink_Delete(t *testing.T) {
}
})
t.Run("emptyToken", func(t *testing.T) {
t.Run("EmptyToken", func(t *testing.T) {
link := Link{ShareUID: "ls6sg6bffgtredft", LinkToken: ""}
assert.Error(t, link.Delete())
})
t.Run("emptyUID", func(t *testing.T) {
t.Run("EmptyUid", func(t *testing.T) {
link := Link{LinkUID: "", ShareUID: "", LinkToken: "abc"}
assert.Error(t, link.Delete())
})
@@ -163,32 +163,32 @@ func TestFindLink(t *testing.T) {
//TODO Why does it fail?
//assert.Equal(t, "1jxf3jfn2k", r.LinkToken)
})
t.Run("nil", func(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
r := FindLink("XXX")
assert.Nil(t, r)
})
}
func TestDeleteShareLinks(t *testing.T) {
t.Run("emptyShareUID", func(t *testing.T) {
t.Run("EmptyShareUid", func(t *testing.T) {
assert.Error(t, DeleteShareLinks(""))
})
}
func TestFindLinks(t *testing.T) {
t.Run("findByToken", func(t *testing.T) {
t.Run("FindByToken", func(t *testing.T) {
r := FindLinks("1jxf3jfn2k", "")
assert.Equal(t, "as6sg6bxpogaaba8", r[0].ShareUID)
})
t.Run("noTokenAndShare", func(t *testing.T) {
t.Run("NoTokenAndShare", func(t *testing.T) {
r := FindLinks("", "")
assert.Empty(t, r)
})
t.Run("invalidToken", func(t *testing.T) {
t.Run("InvalidToken", func(t *testing.T) {
r := FindLinks("lkjh", "")
assert.Empty(t, r)
})
t.Run("findBySlug", func(t *testing.T) {
t.Run("FindBySlug", func(t *testing.T) {
r := FindLinks("", "holiday-2030")
assert.Equal(t, "as6sg6bxpogaaba8", r[0].ShareUID)
})

View File

@@ -7,13 +7,13 @@ import (
)
func TestMarkerMap_Get(t *testing.T) {
t.Run("get existing marker", func(t *testing.T) {
t.Run("GetExistingMarker", func(t *testing.T) {
r := MarkerFixtures.Get("1000003-3")
assert.Equal(t, "Center", r.MarkerName)
assert.Equal(t, float32(0.5), r.Y)
assert.IsType(t, Marker{}, r)
})
t.Run("get not existing marker", func(t *testing.T) {
t.Run("GetNotExistingMarker", func(t *testing.T) {
r := MarkerFixtures.Get("XXX")
assert.Equal(t, *UnknownMarker, r)
assert.IsType(t, Marker{}, r)
@@ -21,13 +21,13 @@ func TestMarkerMap_Get(t *testing.T) {
}
func TestMarkerMap_Pointer(t *testing.T) {
t.Run("get existing marker pointer", func(t *testing.T) {
t.Run("GetExistingMarkerPointer", func(t *testing.T) {
r := MarkerFixtures.Pointer("1000003-3")
assert.Equal(t, "Center", r.MarkerName)
assert.Equal(t, float32(0.5), r.Y)
assert.IsType(t, &Marker{}, r)
})
t.Run("get not existing marker pointer", func(t *testing.T) {
t.Run("GetNotExistingMarkerPointer", func(t *testing.T) {
r := MarkerFixtures.Pointer("XXX")
assert.Equal(t, UnknownMarker, r)
assert.IsType(t, &Marker{}, r)

View File

@@ -86,7 +86,7 @@ func TestMarker_SetName(t *testing.T) {
}
func TestMarker_SaveForm(t *testing.T) {
t.Run("fa-ge add new name to marker then rename marker", func(t *testing.T) {
t.Run("FaGeAddNewNameToMarkerThenRenameMarker", func(t *testing.T) {
m := MarkerFixtures.Get("fa-gr-1")
m2 := MarkerFixtures.Get("fa-gr-2")
m3 := MarkerFixtures.Get("fa-gr-3")
@@ -284,7 +284,7 @@ func TestMarker_Save(t *testing.T) {
p.PreloadFiles()
assert.NotEmpty(t, p.Files)
})
t.Run("invalid position", func(t *testing.T) {
t.Run("InvalidPosition", func(t *testing.T) {
m := Marker{X: -1, Y: 0, W: 0.2, H: 0.133, MarkerType: MarkerFace}
if err := m.Save(); err == nil {
@@ -297,7 +297,7 @@ func TestMarker_Save(t *testing.T) {
}
func TestMarker_ClearSubject(t *testing.T) {
t.Run("1000003-2", func(t *testing.T) {
t.Run("Num1000003Two", func(t *testing.T) {
m := MarkerFixtures.Get("1000003-2")
assert.NotEmpty(t, m.MarkerName)
@@ -310,7 +310,7 @@ func TestMarker_ClearSubject(t *testing.T) {
assert.Empty(t, m.MarkerName)
})
t.Run("actor-1", func(t *testing.T) {
t.Run("ActorOne", func(t *testing.T) {
m := MarkerFixtures.Get("actor-a-4") // id 18
m2 := MarkerFixtures.Get("actor-a-3") // id 17
m3 := MarkerFixtures.Get("actor-a-2") // id 16
@@ -362,7 +362,7 @@ func TestMarker_ClearSubject(t *testing.T) {
}
func TestMarker_ClearFace(t *testing.T) {
t.Run("1000003-2", func(t *testing.T) {
t.Run("Num1000003Two", func(t *testing.T) {
m := MarkerFixtures.Get("1000003-2")
assert.NotEmpty(t, m.FaceID)
@@ -376,7 +376,7 @@ func TestMarker_ClearFace(t *testing.T) {
assert.True(t, updated)
assert.Empty(t, m.FaceID)
})
t.Run("empty face id", func(t *testing.T) {
t.Run("EmptyFaceId", func(t *testing.T) {
m := Marker{FaceID: ""}
updated, err := m.ClearFace()
@@ -388,7 +388,7 @@ func TestMarker_ClearFace(t *testing.T) {
assert.False(t, updated)
assert.Empty(t, m.FaceID)
})
t.Run("subject src manual", func(t *testing.T) {
t.Run("SubjectSrcManual", func(t *testing.T) {
m := Marker{MarkerUID: "mqyz9x61edicxf8j", FaceID: "123ab"}
assert.NotEmpty(t, m.FaceID)
@@ -406,18 +406,18 @@ func TestMarker_ClearFace(t *testing.T) {
}
func TestMarker_SyncSubject(t *testing.T) {
t.Run("no face marker", func(t *testing.T) {
t.Run("NoFaceMarker", func(t *testing.T) {
m := Marker{MarkerType: "test", subject: nil}
assert.Nil(t, m.SyncSubject(false))
})
t.Run("subject is nil", func(t *testing.T) {
t.Run("SubjectIsNil", func(t *testing.T) {
m := Marker{MarkerType: MarkerFace, subject: nil}
assert.Nil(t, m.SyncSubject(false))
})
}
func TestMarker_Create(t *testing.T) {
t.Run("invalid position", func(t *testing.T) {
t.Run("InvalidPosition", func(t *testing.T) {
m := Marker{X: 0, Y: 0, MarkerType: MarkerFace}
err := m.Create()
if err == nil {
@@ -434,13 +434,13 @@ func TestMarker_Embeddings(t *testing.T) {
assert.Equal(t, 0.013083286379677253, m.Embeddings()[0][0])
})
t.Run("empty embedding", func(t *testing.T) {
t.Run("EmptyEmbedding", func(t *testing.T) {
m := Marker{}
m.EmbeddingsJSON = []byte("")
assert.Empty(t, m.Embeddings())
})
t.Run("invalid embedding json", func(t *testing.T) {
t.Run("InvalidEmbeddingJson", func(t *testing.T) {
m := Marker{}
m.EmbeddingsJSON = []byte("[false]")
@@ -449,28 +449,28 @@ func TestMarker_Embeddings(t *testing.T) {
}
func TestMarker_HasFace(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
m := MarkerFixtures.Get("1000003-6")
assert.True(t, m.HasFace(nil, -1))
assert.True(t, m.HasFace(FaceFixtures.Pointer("joe-biden"), -1))
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
m := MarkerFixtures.Get("1000003-6")
assert.False(t, m.HasFace(FaceFixtures.Pointer("joe-biden"), 0.1))
})
t.Run("face id empty", func(t *testing.T) {
t.Run("FaceIdEmpty", func(t *testing.T) {
m := Marker{FaceID: ""}
assert.False(t, m.HasFace(FaceFixtures.Pointer("joe-biden"), 0.1))
})
t.Run("face dist < 0", func(t *testing.T) {
t.Run("FaceDistLessThanZero", func(t *testing.T) {
m := Marker{FaceID: "123", FaceDist: -1}
assert.False(t, m.HasFace(FaceFixtures.Pointer("joe-biden"), 0.1))
})
t.Run("face id = f.ID", func(t *testing.T) {
t.Run("FaceIdEqualFId", func(t *testing.T) {
m := Marker{FaceID: "VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG6"}
assert.True(t, m.HasFace(FaceFixtures.Pointer("joe-biden"), 0.1))
@@ -540,7 +540,7 @@ func TestMarker_GetFace(t *testing.T) {
assert.Nil(t, m.face)
}
})
t.Run("find face with ID", func(t *testing.T) {
t.Run("FindFaceWithId", func(t *testing.T) {
m := Marker{MarkerUID: "ms6sg6b14ahkyd24", FaceID: "VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG6"}
if f := m.Face(); f == nil {
@@ -549,12 +549,12 @@ func TestMarker_GetFace(t *testing.T) {
assert.Equal(t, "VF7ANLDET2BKZNT4VQWJMMC6HBEFDOG6", f.ID)
}
})
t.Run("low quality marker", func(t *testing.T) {
t.Run("LowQualityMarker", func(t *testing.T) {
m := Marker{MarkerUID: "", FaceID: "", SubjSrc: SrcManual, Size: 130}
assert.Nil(t, m.Face())
})
t.Run("create face", func(t *testing.T) {
t.Run("CreateFace", func(t *testing.T) {
m := Marker{
MarkerUID: "ms6sg6b14ahkyd24",
FaceID: "",
@@ -573,32 +573,32 @@ func TestMarker_GetFace(t *testing.T) {
}
func TestFindMarker(t *testing.T) {
t.Run("nil", func(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
assert.Nil(t, FindMarker("0000"))
})
}
func TestMarker_SetFace(t *testing.T) {
t.Run("face == nil", func(t *testing.T) {
t.Run("FaceEqualNil", func(t *testing.T) {
m := MarkerFixtures.Pointer("1000003-6")
assert.Equal(t, "PN6QO5INYTUSAATOFL43LL2ABAV5ACZK", m.FaceID)
updated, _ := m.SetFace(nil, -1)
assert.False(t, updated)
assert.Equal(t, "PN6QO5INYTUSAATOFL43LL2ABAV5ACZK", m.FaceID)
})
t.Run("wrong marker type", func(t *testing.T) {
t.Run("WrongMarkerType", func(t *testing.T) {
m := Marker{MarkerType: "xxx"}
updated, _ := m.SetFace(&Face{ID: "99876"}, -1)
assert.False(t, updated)
assert.Equal(t, "", m.FaceID)
})
t.Run("skip same face", func(t *testing.T) {
t.Run("SkipSameFace", func(t *testing.T) {
m := Marker{MarkerType: MarkerFace, SubjUID: "js6sg6b1qekk9jx8", FaceID: "99876uyt"}
updated, _ := m.SetFace(&Face{ID: "99876uyt", SubjUID: "js6sg6b1qekk9jx8"}, -1)
assert.False(t, updated)
assert.Equal(t, "99876uyt", m.FaceID)
})
t.Run("set new face", func(t *testing.T) {
t.Run("SetNewFace", func(t *testing.T) {
m := Marker{MarkerUID: "mqyz9x61edicxf8j", MarkerType: MarkerFace, SubjUID: "", FaceID: ""}
updated, _ := m.SetFace(FaceFixtures.Pointer("john-doe"), -1)

View File

@@ -7,12 +7,12 @@ import (
)
func TestPasscodeMap_Get(t *testing.T) {
t.Run("get existing passcode", func(t *testing.T) {
t.Run("GetExistingPasscode", func(t *testing.T) {
r := PasscodeFixtures.Get("alice")
assert.Equal(t, "uqxetse3cy5eo9z2", r.UID)
assert.IsType(t, Passcode{}, r)
})
t.Run("get not existing passcode", func(t *testing.T) {
t.Run("GetNotExistingPasscode", func(t *testing.T) {
r := PasscodeFixtures.Get("monstera")
assert.Equal(t, "", r.UID)
assert.IsType(t, Passcode{}, r)
@@ -20,12 +20,12 @@ func TestPasscodeMap_Get(t *testing.T) {
}
func TestPasscodeMap_Pointer(t *testing.T) {
t.Run("get existing passcode", func(t *testing.T) {
t.Run("GetExistingPasscode", func(t *testing.T) {
r := PasscodeFixtures.Pointer("alice")
assert.Equal(t, "uqxetse3cy5eo9z2", r.UID)
assert.IsType(t, &Passcode{}, r)
})
t.Run("get not existing passcode", func(t *testing.T) {
t.Run("GetNotExistingPasscode", func(t *testing.T) {
r := PasscodeFixtures.Pointer("monstera")
assert.Equal(t, "", r.UID)
assert.IsType(t, &Passcode{}, r)

View File

@@ -7,12 +7,12 @@ import (
)
func TestPasswordMap_Get(t *testing.T) {
t.Run("get existing password", func(t *testing.T) {
t.Run("GetExistingPassword", func(t *testing.T) {
r := PasswordFixtures.Get("alice")
assert.Equal(t, "uqxetse3cy5eo9z2", r.UID)
assert.IsType(t, Password{}, r)
})
t.Run("get not existing password", func(t *testing.T) {
t.Run("GetNotExistingPassword", func(t *testing.T) {
r := PasswordFixtures.Get("monstera")
assert.Equal(t, "", r.UID)
assert.IsType(t, Password{}, r)
@@ -20,12 +20,12 @@ func TestPasswordMap_Get(t *testing.T) {
}
func TestPasswordMap_Pointer(t *testing.T) {
t.Run("get existing password", func(t *testing.T) {
t.Run("GetExistingPassword", func(t *testing.T) {
r := PasswordFixtures.Pointer("alice")
assert.Equal(t, "uqxetse3cy5eo9z2", r.UID)
assert.IsType(t, &Password{}, r)
})
t.Run("get not existing password", func(t *testing.T) {
t.Run("GetNotExistingPassword", func(t *testing.T) {
r := PasswordFixtures.Pointer("monstera")
assert.Equal(t, "", r.UID)
assert.IsType(t, &Password{}, r)

View File

@@ -11,7 +11,7 @@ func TestNewPassword(t *testing.T) {
p := NewPassword("urrwaxd19ldtz68x", "passwd", false)
assert.Len(t, p.Hash, 60)
})
t.Run("empty password", func(t *testing.T) {
t.Run("EmptyPassword", func(t *testing.T) {
p := NewPassword("urrwaxd19ldtz68x", "", false)
assert.Equal(t, "", p.Hash)
})
@@ -32,14 +32,14 @@ func TestPassword_SetPassword(t *testing.T) {
assert.True(t, p.Valid("abcd"))
assert.False(t, p.Valid("other"))
})
t.Run("Too long", func(t *testing.T) {
t.Run("TooLong", func(t *testing.T) {
p := NewPassword("urrwaxd19ldtz68x", "hgfttrgkncgdhfkbvuvygvbekdjbrtugbnljbtruhogtgbotuhblenbhoyuhntyyhngytohrpnehotyihniy", false)
err := p.SetPassword("hgfttrgkncgdhfkbvuvygvbekdjbrtugbnljbtruhogtgbotuhblenbhoyuhntyyhngytohrpnehotyihniy", false)
assert.Error(t, err)
})
t.Run("Too short", func(t *testing.T) {
t.Run("TooShort", func(t *testing.T) {
p := NewPassword("urrwaxd19ldtz68x", "", false)
err := p.SetPassword("", false)

View File

@@ -7,13 +7,13 @@ import (
)
func TestPhotoAlbumMap_Get(t *testing.T) {
t.Run("get existing photoalbum", func(t *testing.T) {
t.Run("GetExistingPhotoalbum", func(t *testing.T) {
r := PhotoAlbumFixtures.Get("1", "", "")
assert.Equal(t, "as6sg6bxpogaaba8", r.AlbumUID)
assert.Equal(t, "ps6sg6be2lvl0yh7", r.PhotoUID)
assert.IsType(t, PhotoAlbum{}, r)
})
t.Run("get not existing photoalbum", func(t *testing.T) {
t.Run("GetNotExistingPhotoalbum", func(t *testing.T) {
r := PhotoAlbumFixtures.Get("x", "1234", "5678")
assert.Equal(t, "5678", r.AlbumUID)
assert.Equal(t, "1234", r.PhotoUID)
@@ -22,13 +22,13 @@ func TestPhotoAlbumMap_Get(t *testing.T) {
}
func TestPhotoAlbumMap_Pointer(t *testing.T) {
t.Run("get existing photoalbum pointer", func(t *testing.T) {
t.Run("GetExistingPhotoalbumPointer", func(t *testing.T) {
r := PhotoAlbumFixtures.Pointer("1", "", "")
assert.Equal(t, "as6sg6bxpogaaba8", r.AlbumUID)
assert.Equal(t, "ps6sg6be2lvl0yh7", r.PhotoUID)
assert.IsType(t, &PhotoAlbum{}, r)
})
t.Run("get not existing photoalbum pointer", func(t *testing.T) {
t.Run("GetNotExistingPhotoalbumPointer", func(t *testing.T) {
r := PhotoAlbumFixtures.Pointer("xy", "xxx", "yyy")
assert.Equal(t, "yyy", r.AlbumUID)
assert.Equal(t, "xxx", r.PhotoUID)

View File

@@ -7,7 +7,7 @@ import (
)
func TestNewPhotoAlbum(t *testing.T) {
t.Run("new album", func(t *testing.T) {
t.Run("NewAlbum", func(t *testing.T) {
m := NewPhotoAlbum("ABC", "EFG")
assert.Equal(t, "ABC", m.PhotoUID)
assert.Equal(t, "EFG", m.AlbumUID)
@@ -22,7 +22,7 @@ func TestPhotoAlbum_TableName(t *testing.T) {
}
func TestFirstOrCreatePhotoAlbum(t *testing.T) {
t.Run("existing album", func(t *testing.T) {
t.Run("ExistingAlbum", func(t *testing.T) {
model := PhotoAlbumFixtures.Get("1", "ps6sg6be2lvl0yh7", "as6sg6bxpogaaba8")
result := FirstOrCreatePhotoAlbum(&model)
@@ -39,7 +39,7 @@ func TestFirstOrCreatePhotoAlbum(t *testing.T) {
}
})
//TODO fails on mariadb
t.Run("not yet existing album", func(t *testing.T) {
t.Run("NotYetExistingAlbum", func(t *testing.T) {
model := &PhotoAlbum{}
result := FirstOrCreatePhotoAlbum(model)

View File

@@ -211,7 +211,7 @@ func TestPhoto_SetTakenAt(t *testing.T) {
assert.Equal(t, time.Date(2014, 12, 11, 9, 7, 18, 0, time.UTC), photo.TakenAt)
assert.Equal(t, time.Date(2014, 12, 11, 9, 7, 18, 0, time.Local), photo.TakenAtLocal)
})
t.Run("KeepTimezoneIfLocationWasSetManually-Local", func(t *testing.T) {
t.Run("KeepTimezoneIfLocationWasSetManuallyLocal", func(t *testing.T) {
photo := &Photo{TakenAtLocal: time.Date(2014, 12, 11, 9, 7, 18, 0, time.UTC), TakenAt: time.Date(2014, 12, 11, 8, 7, 18, 0, time.UTC), TimeZone: "Europe/Berlin", TakenSrc: "meta", PhotoLat: 52.48498888888889, PhotoLng: 13.190422222222223, PhotoCountry: "de", PlaceSrc: "manual"}
assert.Equal(t, "Europe/Berlin", photo.TimeZone)
photo.SetTakenAt(time.Date(2014, 12, 11, 9, 7, 18, 0, time.Local),
@@ -220,7 +220,7 @@ func TestPhoto_SetTakenAt(t *testing.T) {
assert.Equal(t, time.Date(2014, 12, 11, 8, 7, 18, 0, time.UTC), photo.TakenAt)
assert.Equal(t, time.Date(2014, 12, 11, 9, 7, 18, 0, time.Local), photo.TakenAtLocal)
})
t.Run("KeepTimezoneIfLocationWasSetManually-UTC", func(t *testing.T) {
t.Run("KeepTimezoneIfLocationWasSetManuallyUtc", func(t *testing.T) {
photo := &Photo{PhotoType: "video", TakenAtLocal: time.Date(2015, 05, 17, 19, 48, 22, 0, time.UTC), TakenAt: time.Date(2015, 05, 17, 17, 48, 22, 0, time.UTC), TimeZone: "Europe/Berlin", TakenSrc: "meta", PhotoLat: 52.48498888888889, PhotoLng: 13.190422222222223, PhotoCountry: "de", PlaceSrc: "manual"}
assert.Equal(t, "Europe/Berlin", photo.TimeZone)
photo.SetTakenAt(time.Date(2015, 05, 17, 17, 48, 22, 0, time.UTC),
@@ -351,7 +351,7 @@ func TestPhoto_UpdateTimeZone(t *testing.T) {
assert.Equal(t, takenAt, m.TakenAt)
assert.Equal(t, m.GetTakenAtLocal(), m.TakenAtLocal)
})
t.Run("Europe/Berlin", func(t *testing.T) {
t.Run("EuropeBerlin", func(t *testing.T) {
m := PhotoFixtures.Get("Photo12")
takenAt := m.TakenAt
@@ -369,7 +369,7 @@ func TestPhoto_UpdateTimeZone(t *testing.T) {
assert.Equal(t, takenAtLocal, m.TakenAtLocal)
assert.Equal(t, m.GetTakenAtLocal(), m.TakenAtLocal)
})
t.Run("America/New_York", func(t *testing.T) {
t.Run("AmericaNewYork", func(t *testing.T) {
m := PhotoFixtures.Get("Photo12")
m.TimeZone = "Europe/Berlin"
m.TakenAt = m.GetTakenAt()
@@ -388,7 +388,7 @@ func TestPhoto_UpdateTimeZone(t *testing.T) {
assert.Equal(t, m.GetTakenAt(), m.TakenAt)
assert.Equal(t, takenAtLocal, m.TakenAtLocal)
})
t.Run("manual", func(t *testing.T) {
t.Run("Manual", func(t *testing.T) {
m := PhotoFixtures.Get("Photo12")
m.TimeZone = "Europe/Berlin"
m.TakenAt = m.GetTakenAt()
@@ -409,7 +409,7 @@ func TestPhoto_UpdateTimeZone(t *testing.T) {
assert.Equal(t, takenAtLocal, m.TakenAtLocal)
assert.Equal(t, "Europe/Berlin", m.TimeZone)
})
t.Run("zone = UTC", func(t *testing.T) {
t.Run("ZoneEqualUtc", func(t *testing.T) {
photo := &Photo{TakenAt: time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC), TimeZone: "Europe/Berlin"}
photo.UpdateTimeZone("")
assert.Equal(t, time.Date(2015, 11, 11, 9, 7, 18, 0, time.UTC), photo.TakenAt)

View File

@@ -103,7 +103,7 @@ func TestPhoto_EstimateCountry(t *testing.T) {
assert.Equal(t, "zz", m.CountryCode())
assert.Equal(t, "Unknown", m.CountryName())
})
t.Run("Los Angeles", func(t *testing.T) {
t.Run("LosAngeles", func(t *testing.T) {
m := Photo{
CameraID: 2,
PhotoType: MediaImage,

View File

@@ -7,13 +7,13 @@ import (
)
func TestPhotoMap_Get(t *testing.T) {
t.Run("get existing photo", func(t *testing.T) {
t.Run("GetExistingPhoto", func(t *testing.T) {
r := PhotoFixtures.Get("19800101_000002_D640C559")
assert.Equal(t, "ps6sg6be2lvl0yh7", r.PhotoUID)
assert.Equal(t, "27900704_070228_D6D51B6C", r.PhotoName)
assert.IsType(t, Photo{}, r)
})
t.Run("get not existing photo", func(t *testing.T) {
t.Run("GetNotExistingPhoto", func(t *testing.T) {
r := PhotoFixtures.Get("TestName")
assert.Equal(t, "TestName", r.PhotoName)
assert.IsType(t, Photo{}, r)
@@ -21,13 +21,13 @@ func TestPhotoMap_Get(t *testing.T) {
}
func TestPhotoMap_Pointer(t *testing.T) {
t.Run("get existing photo pointer", func(t *testing.T) {
t.Run("GetExistingPhotoPointer", func(t *testing.T) {
r := PhotoFixtures.Pointer("19800101_000002_D640C559")
assert.Equal(t, "ps6sg6be2lvl0yh7", r.PhotoUID)
assert.Equal(t, "27900704_070228_D6D51B6C", r.PhotoName)
assert.IsType(t, &Photo{}, r)
})
t.Run("get not existing photo pointer", func(t *testing.T) {
t.Run("GetNotExistingPhotoPointer", func(t *testing.T) {
r := PhotoFixtures.Pointer("TestName2")
assert.Equal(t, "TestName2", r.PhotoName)
assert.IsType(t, &Photo{}, r)

View File

@@ -7,7 +7,7 @@ import (
)
func TestNewPhotoKeyword(t *testing.T) {
t.Run("new keyword", func(t *testing.T) {
t.Run("NewKeyword", func(t *testing.T) {
m := NewPhotoKeyword(uint(3), uint(8))
assert.Equal(t, uint(3), m.PhotoID)
assert.Equal(t, uint(8), m.KeywordID)

View File

@@ -9,7 +9,7 @@ import (
)
func TestNewPhotoLabel(t *testing.T) {
t.Run("name Christmas 2018", func(t *testing.T) {
t.Run("NameChristmasNum2018", func(t *testing.T) {
photoLabel := NewPhotoLabel(1, 3, 80, "source")
assert.Equal(t, uint(0x1), photoLabel.PhotoID)
assert.Equal(t, uint(0x3), photoLabel.LabelID)
@@ -72,7 +72,7 @@ func TestPhotoLabel_Save(t *testing.T) {
}
})
//TODO fails on mariadb
t.Run("photo not nil and label not nil", func(t *testing.T) {
t.Run("PhotoNotNilAndLabelNotNil", func(t *testing.T) {
label := &Label{LabelName: "LabelSaveUnique", LabelSlug: "unique-slug"}
photo := &Photo{}

View File

@@ -161,7 +161,7 @@ func TestPhoto_SetAltitude(t *testing.T) {
}
func TestPhoto_SetCoordinates(t *testing.T) {
t.Run("empty coordinates", func(t *testing.T) {
t.Run("EmptyCoordinates", func(t *testing.T) {
m := PhotoFixtures.Get("Photo15")
assert.Equal(t, SrcMeta, m.PlaceSrc)
assert.Equal(t, float32(48.51885), float32(m.PhotoLat))
@@ -174,7 +174,7 @@ func TestPhoto_SetCoordinates(t *testing.T) {
assert.Equal(t, float32(9.0531866), float32(m.PhotoLng))
assert.Equal(t, 5, m.PhotoAltitude)
})
t.Run("same source new values", func(t *testing.T) {
t.Run("SameSourceNewValues", func(t *testing.T) {
m := PhotoFixtures.Get("Photo15")
assert.Equal(t, SrcMeta, m.PlaceSrc)
assert.Equal(t, float32(48.51885), float32(m.PhotoLat))
@@ -187,7 +187,7 @@ func TestPhoto_SetCoordinates(t *testing.T) {
assert.Equal(t, float32(5.555), float32(m.PhotoLng))
assert.Equal(t, 5, m.PhotoAltitude)
})
t.Run("different source lower priority", func(t *testing.T) {
t.Run("DifferentSourceLowerPriority", func(t *testing.T) {
m := PhotoFixtures.Get("Photo15")
assert.Equal(t, SrcMeta, m.PlaceSrc)
assert.Equal(t, float32(48.51885), float32(m.PhotoLat))
@@ -200,7 +200,7 @@ func TestPhoto_SetCoordinates(t *testing.T) {
assert.Equal(t, float32(9.0531866), float32(m.PhotoLng))
assert.Equal(t, 3, m.PhotoAltitude)
})
t.Run("different source equal priority", func(t *testing.T) {
t.Run("DifferentSourceEqualPriority", func(t *testing.T) {
m := PhotoFixtures.Get("Photo15")
assert.Equal(t, SrcMeta, m.PlaceSrc)
assert.Equal(t, float32(48.51885), float32(m.PhotoLat))
@@ -212,7 +212,7 @@ func TestPhoto_SetCoordinates(t *testing.T) {
assert.Equal(t, float32(5.555), float32(m.PhotoLng))
assert.Equal(t, 5, m.PhotoAltitude)
})
t.Run("different source higher priority", func(t *testing.T) {
t.Run("DifferentSourceHigherPriority", func(t *testing.T) {
m := PhotoFixtures.Get("Photo21")
assert.Equal(t, SrcEstimate, m.PlaceSrc)
assert.Equal(t, 0.0, m.PhotoLat)
@@ -225,7 +225,7 @@ func TestPhoto_SetCoordinates(t *testing.T) {
assert.Equal(t, float32(5.555), float32(m.PhotoLng))
assert.Equal(t, 5, m.PhotoAltitude)
})
t.Run("different source highest priority (manual)", func(t *testing.T) {
t.Run("DifferentSourceHighestPriorityManual", func(t *testing.T) {
m := PhotoFixtures.Get("Photo15")
assert.Equal(t, SrcMeta, m.PlaceSrc)
assert.Equal(t, float32(48.51885), float32(m.PhotoLat))
@@ -241,11 +241,11 @@ func TestPhoto_SetCoordinates(t *testing.T) {
}
func TestPhoto_UnknownLocation(t *testing.T) {
t.Run("no_location", func(t *testing.T) {
t.Run("NoLocation", func(t *testing.T) {
m := PhotoFixtures.Get("19800101_000002_D640C559")
assert.True(t, m.UnknownLocation())
})
t.Run("no_lat_lng", func(t *testing.T) {
t.Run("NoLatLng", func(t *testing.T) {
m := PhotoFixtures.Get("Photo08")
m.PhotoLat = 0.0
m.PhotoLng = 0.0
@@ -253,7 +253,7 @@ func TestPhoto_UnknownLocation(t *testing.T) {
assert.False(t, m.HasLocation())
assert.True(t, m.UnknownLocation())
})
t.Run("lat_lng_cell_id", func(t *testing.T) {
t.Run("LatLngCellId", func(t *testing.T) {
m := PhotoFixtures.Get("Photo08")
// t.Logf("MODEL: %+v", m)
assert.True(t, m.HasLocation())
@@ -281,7 +281,7 @@ func TestPhoto_TrustedLocation(t *testing.T) {
}
func TestPhoto_HasLocation(t *testing.T) {
t.Run("19800101_000002_D640C559", func(t *testing.T) {
t.Run("Num19800101Num000002DNum640CNum559", func(t *testing.T) {
m := PhotoFixtures.Get("19800101_000002_D640C559")
assert.False(t, m.HasLocation())
})
@@ -320,7 +320,7 @@ func TestPhoto_NoLatLng(t *testing.T) {
}
func TestPhoto_NoPlace(t *testing.T) {
t.Run("19800101_000002_D640C559", func(t *testing.T) {
t.Run("Num19800101Num000002DNum640CNum559", func(t *testing.T) {
m := PhotoFixtures.Get("19800101_000002_D640C559")
assert.True(t, m.UnknownPlace())
})
@@ -331,7 +331,7 @@ func TestPhoto_NoPlace(t *testing.T) {
}
func TestPhoto_HasPlace(t *testing.T) {
t.Run("19800101_000002_D640C559", func(t *testing.T) {
t.Run("Num19800101Num000002DNum640CNum559", func(t *testing.T) {
m := PhotoFixtures.Get("19800101_000002_D640C559")
assert.False(t, m.HasPlace())
})
@@ -390,7 +390,7 @@ func TestPhoto_CountryName(t *testing.T) {
}
func TestUpdateLocation(t *testing.T) {
t.Run("estimate", func(t *testing.T) {
t.Run("Estimate", func(t *testing.T) {
m := Photo{
PhotoName: "test_photo_2",
PhotoCountry: UnknownID,
@@ -411,7 +411,7 @@ func TestUpdateLocation(t *testing.T) {
assert.Equal(t, "mx:VvfNBpFegSCr", m.PlaceID)
assert.Equal(t, SrcEstimate, m.PlaceSrc)
})
t.Run("change_estimate", func(t *testing.T) {
t.Run("ChangeEstimate", func(t *testing.T) {
m := Photo{
PhotoName: "test_photo_1",
PhotoCountry: "de",

View File

@@ -47,7 +47,7 @@ func TestPhoto_IdenticalIdentical(t *testing.T) {
t.Logf("result: %#v", result)
assert.Equal(t, 1, len(result))
})
t.Run("unstacked photo", func(t *testing.T) {
t.Run("UnstackedPhoto", func(t *testing.T) {
photo := &Photo{PhotoStack: IsUnstacked, PhotoName: "testName"}
result, err := photo.Identical(true, true)

View File

@@ -7,7 +7,7 @@ import (
)
func TestPhoto_Optimize(t *testing.T) {
t.Run("update", func(t *testing.T) {
t.Run("Update", func(t *testing.T) {
photo := PhotoFixtures.Get("Photo19")
if updated, merged, err := photo.Optimize(false, false, true, false); err != nil {
@@ -26,7 +26,7 @@ func TestPhoto_Optimize(t *testing.T) {
t.Errorf("no photos should be merged")
}
})
t.Run("photo without id", func(t *testing.T) {
t.Run("PhotoWithoutId", func(t *testing.T) {
photo := Photo{}
result, merged, err := photo.Optimize(false, false, true, false)
assert.Error(t, err)

View File

@@ -7,19 +7,19 @@ import (
)
func TestPhoto_QualityScore(t *testing.T) {
t.Run("PhotoFixture19800101_000002_D640C559", func(t *testing.T) {
t.Run("PhotoFixtureNum19800101Num000002DNum640CNum559", func(t *testing.T) {
assert.Equal(t, 3, PhotoFixtures.Pointer("19800101_000002_D640C559").QualityScore())
})
t.Run("PhotoFixturePhoto01 - favorite true - taken at before 2008", func(t *testing.T) {
t.Run("PhotoFixturePhotoNum01FavoriteTrueTakenAtBeforeNum2008", func(t *testing.T) {
assert.Equal(t, 7, PhotoFixtures.Pointer("Photo01").QualityScore())
})
t.Run("PhotoFixturePhoto06 - taken at after 2012 - resolution 2", func(t *testing.T) {
t.Run("PhotoFixturePhotoNum06TakenAtAfterNum2012ResolutionTwo", func(t *testing.T) {
assert.Equal(t, 3, PhotoFixtures.Pointer("Photo06").QualityScore())
})
t.Run("PhotoFixturePhoto07 - score < 3 bit edited", func(t *testing.T) {
t.Run("PhotoFixturePhotoNum07ScoreLessThanThreeBitEdited", func(t *testing.T) {
assert.Equal(t, 3, PhotoFixtures.Pointer("Photo07").QualityScore())
})
t.Run("PhotoFixturePhoto15 - description with non-photographic", func(t *testing.T) {
t.Run("PhotoFixturePhotoFifteenDescriptionWithNonPhotographic", func(t *testing.T) {
assert.Equal(t, 2, PhotoFixtures.Pointer("Photo15").QualityScore())
})
}

View File

@@ -9,22 +9,22 @@ import (
)
func TestPhoto_HasTitle(t *testing.T) {
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
m := PhotoFixtures.Get("Photo03")
assert.False(t, m.HasTitle())
})
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
m := PhotoFixtures.Get("Photo04")
assert.True(t, m.HasTitle())
})
}
func TestPhoto_NoTitle(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
m := PhotoFixtures.Get("Photo03")
assert.True(t, m.NoTitle())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
m := PhotoFixtures.Get("Photo04")
assert.False(t, m.NoTitle())
})
@@ -61,7 +61,7 @@ func TestPhoto_SetTitle(t *testing.T) {
}
func TestPhoto_GenerateTitle(t *testing.T) {
t.Run("won't update title was modified", func(t *testing.T) {
t.Run("WonTUpdateTitleWasModified", func(t *testing.T) {
m := PhotoFixtures.Get("Photo08")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Black beach", m.PhotoTitle)
@@ -71,7 +71,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "Black beach", m.PhotoTitle)
})
t.Run("photo with location without city and label", func(t *testing.T) {
t.Run("PhotoWithLocationWithoutCityAndLabel", func(t *testing.T) {
m := PhotoFixtures.Get("Photo10")
classifyLabels := &classify.Labels{{Name: "tree", Uncertainty: 30, Source: "manual", Priority: 5, Categories: []string{"plant"}}}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -86,7 +86,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
assert.Equal(t, "Tree / Germany / 2016", m.PhotoTitle)
}
})
t.Run("photo with location and short city and label", func(t *testing.T) {
t.Run("PhotoWithLocationAndShortCityAndLabel", func(t *testing.T) {
m := PhotoFixtures.Get("Photo09")
classifyLabels := &classify.Labels{{Name: "tree", Uncertainty: 30, Source: "manual", Priority: 5, Categories: []string{"plant"}}}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -96,7 +96,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "Tree / Teotihuacán / 2016", m.PhotoTitle)
})
t.Run("photo with location and locname >45", func(t *testing.T) {
t.Run("PhotoWithLocationAndLocnameGreaterThanNum45", func(t *testing.T) {
m := PhotoFixtures.Get("Photo13")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -106,7 +106,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "LonglonglonglonglonglonglonglonglonglonglonglonglongName", m.PhotoTitle)
})
t.Run("photo with location and locname >20", func(t *testing.T) {
t.Run("PhotoWithLocationAndLocnameGreaterThanTwenty", func(t *testing.T) {
m := PhotoFixtures.Get("Photo14")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -116,7 +116,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "longlonglonglonglonglongName / 2018", m.PhotoTitle)
})
t.Run("photo with location and short city", func(t *testing.T) {
t.Run("PhotoWithLocationAndShortCity", func(t *testing.T) {
m := PhotoFixtures.Get("Photo09")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -126,7 +126,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "Adosada Platform / Teotihuacán / 2016", m.PhotoTitle)
})
t.Run("photo with location without city", func(t *testing.T) {
t.Run("PhotoWithLocationWithoutCity", func(t *testing.T) {
m := PhotoFixtures.Get("Photo10")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -142,7 +142,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
assert.Equal(t, "Holiday Park / Germany / 2016", m.PhotoTitle)
}
})
t.Run("photo with location without loc name and long city", func(t *testing.T) {
t.Run("PhotoWithLocationWithoutLocNameAndLongCity", func(t *testing.T) {
m := PhotoFixtures.Get("Photo11")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -152,7 +152,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "longlonglonglonglongcity / 2016", m.PhotoTitle)
})
t.Run("photo with location without loc name and short city", func(t *testing.T) {
t.Run("PhotoWithLocationWithoutLocNameAndShortCity", func(t *testing.T) {
m := PhotoFixtures.Get("Photo12")
classifyLabels := &classify.Labels{}
assert.Equal(t, "Title", m.PhotoTitle)
@@ -162,7 +162,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "shortcity / Germany / 2016", m.PhotoTitle)
})
t.Run("no location original name", func(t *testing.T) {
t.Run("NoLocationOriginalName", func(t *testing.T) {
m := PhotoFixtures.Get("19800101_000002_D640C559")
classifyLabels := &classify.Labels{{Name: "classify", Uncertainty: 30, Source: SrcManual, Priority: 5, Categories: []string{"flower", "plant"}}}
assert.Equal(t, "Lake / 2790", m.PhotoTitle)
@@ -172,7 +172,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "Franzilein & Actress A / 2008", m.PhotoTitle)
})
t.Run("no location", func(t *testing.T) {
t.Run("NoLocation", func(t *testing.T) {
m := PhotoFixtures.Get("Photo01")
classifyLabels := &classify.Labels{{Name: "classify", Uncertainty: 30, Source: SrcManual, Priority: 5, Categories: []string{"flower", "plant"}}}
assert.Equal(t, "", m.PhotoTitle)
@@ -182,7 +182,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
}
assert.Equal(t, "Classify / Germany / 2006", m.PhotoTitle)
})
t.Run("no location no labels", func(t *testing.T) {
t.Run("NoLocationNoLabels", func(t *testing.T) {
m := PhotoFixtures.Get("Photo02")
classifyLabels := &classify.Labels{}
assert.Equal(t, "", m.PhotoTitle)
@@ -198,7 +198,7 @@ func TestPhoto_GenerateTitle(t *testing.T) {
assert.Equal(t, "Bridge1 / 1990", m.PhotoTitle)
}
})
t.Run("no location no labels no takenAt", func(t *testing.T) {
t.Run("NoLocationNoLabelsNoTakenAt", func(t *testing.T) {
m := PhotoFixtures.Get("Photo20")
classifyLabels := &classify.Labels{}
assert.Equal(t, "", m.PhotoTitle)

View File

@@ -7,13 +7,13 @@ import (
)
func TestPlaceMap_Get(t *testing.T) {
t.Run("get existing place", func(t *testing.T) {
t.Run("GetExistingPlace", func(t *testing.T) {
r := PlaceFixtures.Get("mexico")
assert.Equal(t, "Teotihuacán", r.PlaceCity)
assert.Equal(t, "State of Mexico", r.PlaceState)
assert.IsType(t, Place{}, r)
})
t.Run("get not existing place", func(t *testing.T) {
t.Run("GetNotExistingPlace", func(t *testing.T) {
r := PlaceFixtures.Get("xxx")
assert.Equal(t, "Unknown", r.PlaceCity)
assert.Equal(t, "Unknown", r.PlaceState)
@@ -22,13 +22,13 @@ func TestPlaceMap_Get(t *testing.T) {
}
func TestPlaceMap_Pointer(t *testing.T) {
t.Run("get existing place pointer", func(t *testing.T) {
t.Run("GetExistingPlacePointer", func(t *testing.T) {
r := PlaceFixtures.Pointer("mexico")
assert.Equal(t, "Teotihuacán", r.PlaceCity)
assert.Equal(t, "State of Mexico", r.PlaceState)
assert.IsType(t, &Place{}, r)
})
t.Run("get not existing place pointer", func(t *testing.T) {
t.Run("GetNotExistingPlacePointer", func(t *testing.T) {
r := PlaceFixtures.Pointer("xxx")
assert.Equal(t, "Unknown", r.PlaceCity)
assert.Equal(t, "Unknown", r.PlaceState)

View File

@@ -12,7 +12,7 @@ func TestCreateUnknownPlace(t *testing.T) {
}
func TestFindPlace(t *testing.T) {
t.Run("Holiday Park", func(t *testing.T) {
t.Run("HolidayPark", func(t *testing.T) {
r := FindPlace("de:HFqPHxa2Hsol")
if r == nil {
@@ -38,14 +38,14 @@ func TestFindPlace(t *testing.T) {
assert.Equal(t, "za", r.PlaceCountry)
})
t.Run("not matching", func(t *testing.T) {
t.Run("NotMatching", func(t *testing.T) {
r := FindPlace("111")
if r != nil {
t.Fatal("result should be nil")
}
})
t.Run("not matching empty label", func(t *testing.T) {
t.Run("NotMatchingEmptyLabel", func(t *testing.T) {
r := FindPlace("111")
if r != nil {
@@ -55,49 +55,49 @@ func TestFindPlace(t *testing.T) {
}
func TestFirstOrCreatePlace(t *testing.T) {
t.Run("existing place", func(t *testing.T) {
t.Run("ExistingPlace", func(t *testing.T) {
m := PlaceFixtures.Pointer("zinkwazi")
r := FirstOrCreatePlace(m)
assert.Equal(t, "KwaDukuza, KwaZulu-Natal, South Africa", r.PlaceLabel)
})
t.Run("ID empty", func(t *testing.T) {
t.Run("IdEmpty", func(t *testing.T) {
p := &Place{ID: ""}
assert.Nil(t, FirstOrCreatePlace(p))
})
t.Run("PlaceLabel empty", func(t *testing.T) {
t.Run("PlaceLabelEmpty", func(t *testing.T) {
p := &Place{ID: "abcde44", PlaceLabel: ""}
assert.Nil(t, FirstOrCreatePlace(p))
})
}
func TestPlace_LongCity(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
p := Place{PlaceCity: "veryveryveryverylongcity"}
assert.True(t, p.LongCity())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
p := Place{PlaceCity: "short"}
assert.False(t, p.LongCity())
})
}
func TestPlace_NoCity(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
p := Place{PlaceCity: ""}
assert.True(t, p.NoCity())
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
p := Place{PlaceCity: "short"}
assert.False(t, p.NoCity())
})
}
func TestPlace_CityContains(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("True", func(t *testing.T) {
p := Place{PlaceCity: "Munich"}
assert.True(t, p.CityContains("Munich"))
})
t.Run("false", func(t *testing.T) {
t.Run("False", func(t *testing.T) {
p := Place{PlaceCity: "short"}
assert.False(t, p.CityContains("ich"))
})

View File

@@ -7,7 +7,7 @@ import (
)
func TestAccountByID(t *testing.T) {
t.Run("existing account", func(t *testing.T) {
t.Run("ExistingAccount", func(t *testing.T) {
r, err := AccountByID(uint(1000001))
if err != nil {
@@ -17,7 +17,7 @@ func TestAccountByID(t *testing.T) {
assert.Equal(t, "Test Account2", r.AccName)
})
t.Run("record not found", func(t *testing.T) {
t.Run("RecordNotFound", func(t *testing.T) {
r, err := AccountByID(uint(123))
if err == nil {

View File

@@ -11,7 +11,7 @@ import (
func TestAccountUploads(t *testing.T) {
a := entity.Service{ID: 1, SyncRaw: false}
t.Run("find uploads", func(t *testing.T) {
t.Run("FindUploads", func(t *testing.T) {
results, err := AccountUploads(a, 10)
if err != nil {

View File

@@ -33,7 +33,7 @@ func TestAlbumByUID(t *testing.T) {
}
func TestAlbumCoverByUID(t *testing.T) {
t.Run("existing uid default album", func(t *testing.T) {
t.Run("ExistingUidDefaultAlbum", func(t *testing.T) {
file, err := AlbumCoverByUID("as6sg6bxpogaaba8", true)
if err != nil {
@@ -42,7 +42,7 @@ func TestAlbumCoverByUID(t *testing.T) {
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
})
t.Run("existing uid folder album", func(t *testing.T) {
t.Run("ExistingUidFolderAlbum", func(t *testing.T) {
file, err := AlbumCoverByUID("as6sg6bipogaaba1", true)
if err != nil {
@@ -51,18 +51,18 @@ func TestAlbumCoverByUID(t *testing.T) {
assert.Equal(t, "1990/04/bridge2.jpg", file.FileName)
})
t.Run("existing uid empty moment album", func(t *testing.T) {
t.Run("ExistingUidEmptyMomentAlbum", func(t *testing.T) {
file, err := AlbumCoverByUID("as6sg6bitoga0005", true)
assert.EqualError(t, err, "no cover found", err)
assert.Equal(t, "", file.FileName)
})
t.Run("not existing uid", func(t *testing.T) {
t.Run("NotExistingUid", func(t *testing.T) {
file, err := AlbumCoverByUID("3765", true)
assert.Error(t, err, "record not found")
t.Log(file)
})
t.Run("existing uid empty month album", func(t *testing.T) {
t.Run("ExistingUidEmptyMonthAlbum", func(t *testing.T) {
file, err := AlbumCoverByUID("as6sg6bipogaabj9", true)
assert.EqualError(t, err, "no cover found", err)

View File

@@ -15,7 +15,7 @@ func TestDuplicates(t *testing.T) {
t.Fatal("files must not be nil")
}
})
t.Run("pathname not empty", func(t *testing.T) {
t.Run("PathnameNotEmpty", func(t *testing.T) {
files, err := Duplicates(10, 0, "/holiday/sea.jpg")
if err != nil {

View File

@@ -8,7 +8,7 @@ import (
// TODO test non empty case
func TestErrors(t *testing.T) {
t.Run("not existing", func(t *testing.T) {
t.Run("NotExisting", func(t *testing.T) {
errors, err := Errors(1000, 0, "notexistingErrorString")
if err != nil {
t.Fatal(err)
@@ -22,7 +22,7 @@ func TestErrors(t *testing.T) {
}
assert.Empty(t, errors)
})
t.Run("warning", func(t *testing.T) {
t.Run("Warning", func(t *testing.T) {
errors, err := Errors(1000, 0, "warnings")
if err != nil {
t.Fatal(err)

View File

@@ -79,7 +79,7 @@ func TestManuallyAddedFaces(t *testing.T) {
assert.Empty(t, results)
})
t.Run("Specific Subject", func(t *testing.T) {
t.Run("SpecificSubject", func(t *testing.T) {
results, err := ManuallyAddedFaces(false, false, "foobar")
if err != nil {
@@ -137,16 +137,16 @@ func TestRemoveAnonymousFaceClusters(t *testing.T) {
}
func TestCountNewFaceMarkers(t *testing.T) {
t.Run("all", func(t *testing.T) {
t.Run("All", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(0, 0), 1)
})
t.Run("score 10", func(t *testing.T) {
t.Run("ScoreTen", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(0, 10), 1)
})
t.Run("size 160", func(t *testing.T) {
t.Run("SizeNum160", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(160, 0), 1)
})
t.Run("score 50 and size 160", func(t *testing.T) {
t.Run("ScoreNum50AndSizeNum160", func(t *testing.T) {
assert.GreaterOrEqual(t, CountNewFaceMarkers(160, 50), 1)
})
}

View File

@@ -10,7 +10,7 @@ import (
)
func TestFileShares(t *testing.T) {
t.Run("search for id and status", func(t *testing.T) {
t.Run("SearchForIdAndStatus", func(t *testing.T) {
r, err := FileShares(uint(1000001), "new")
if err != nil {
t.Fatal(err)
@@ -24,7 +24,7 @@ func TestFileShares(t *testing.T) {
}
func TestExpiredFileShares(t *testing.T) {
t.Run("expired file share exists", func(t *testing.T) {
t.Run("ExpiredFileShareExists", func(t *testing.T) {
time.Sleep(2 * time.Second)
r, err := ExpiredFileShares(entity.ServiceFixtureWebdavDummy)
if err != nil {
@@ -36,7 +36,7 @@ func TestExpiredFileShares(t *testing.T) {
assert.IsType(t, entity.FileShare{}, r)
}
})
t.Run("expired file does not exists", func(t *testing.T) {
t.Run("ExpiredFileDoesNotExists", func(t *testing.T) {
r, err := ExpiredFileShares(entity.ServiceFixtureWebdavDummy2)
if err != nil {
t.Fatal(err)

View File

@@ -13,7 +13,7 @@ func TestSetDownloadFileID(t *testing.T) {
t.Fatal(err)
}
})
t.Run("filename empty", func(t *testing.T) {
t.Run("FilenameEmpty", func(t *testing.T) {
err := SetDownloadFileID("", 1000000)
if err == nil {
t.Fatal()

Some files were not shown because too many files have changed in this diff Show More