Backend: Add unit tests for internal/entity

This commit is contained in:
Theresa Gresch
2020-07-08 17:36:06 +02:00
parent 3e6c21a566
commit e1487238e6
2 changed files with 25 additions and 0 deletions

View File

@@ -16,6 +16,24 @@ func TestFirstOrCreateCamera(t *testing.T) {
t.Fatal("result should not be nil")
}
assert.GreaterOrEqual(t, result.ID, uint(1))
})
t.Run("camera without make and model", func(t *testing.T) {
camera := &Camera{ID: 10000000, CameraSlug: "camera-slug"}
result := FirstOrCreateCamera(camera)
if result == nil {
t.Fatal("result should not be nil")
}
assert.GreaterOrEqual(t, result.ID, uint(1))
})
t.Run("not existing model and make", func(t *testing.T) {
camera := &Camera{CameraModel: "xxx", CameraMake: "xxx"}
result := FirstOrCreateCamera(camera)
assert.GreaterOrEqual(t, result.ID, uint(1))
})
}