2019-12-11 16:55:18 +01:00
|
|
|
package entity
|
2019-05-03 18:57:28 +02:00
|
|
|
|
|
|
|
import (
|
2019-07-16 12:36:30 +02:00
|
|
|
"testing"
|
2019-12-11 14:10:20 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-05-03 18:57:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewCamera(t *testing.T) {
|
2019-07-16 12:36:30 +02:00
|
|
|
t.Run("model Unknown make Nikon", func(t *testing.T) {
|
|
|
|
camera := NewCamera("", "Nikon")
|
|
|
|
|
|
|
|
expected := &Camera{
|
|
|
|
CameraModel: "Unknown",
|
|
|
|
CameraMake: "Nikon",
|
|
|
|
CameraSlug: "nikon-unknown",
|
|
|
|
}
|
|
|
|
assert.Equal(t, expected, camera)
|
|
|
|
})
|
|
|
|
t.Run("model EOS 6D make Canon", func(t *testing.T) {
|
|
|
|
camera := NewCamera("EOS 6D", "Canon")
|
|
|
|
|
|
|
|
expected := &Camera{
|
|
|
|
CameraModel: "EOS 6D",
|
|
|
|
CameraMake: "Canon",
|
|
|
|
CameraSlug: "canon-eos-6d",
|
|
|
|
}
|
|
|
|
assert.Equal(t, expected, camera)
|
|
|
|
})
|
|
|
|
t.Run("model with prefix make Panasonic", func(t *testing.T) {
|
|
|
|
camera := NewCamera("Panasonic Lumix", "Panasonic")
|
|
|
|
|
|
|
|
expected := &Camera{
|
|
|
|
CameraModel: "Lumix",
|
|
|
|
CameraMake: "Panasonic",
|
|
|
|
CameraSlug: "panasonic-lumix",
|
|
|
|
}
|
|
|
|
assert.Equal(t, expected, camera)
|
|
|
|
})
|
2019-07-16 14:11:33 +02:00
|
|
|
t.Run("model TG-4 make Unknown", func(t *testing.T) {
|
2019-07-16 12:36:30 +02:00
|
|
|
camera := NewCamera("TG-4", "")
|
|
|
|
|
|
|
|
expected := &Camera{
|
|
|
|
CameraModel: "TG-4",
|
|
|
|
CameraMake: "",
|
|
|
|
CameraSlug: "tg-4",
|
|
|
|
}
|
|
|
|
assert.Equal(t, expected, camera)
|
|
|
|
})
|
2019-07-16 14:11:33 +02:00
|
|
|
t.Run("model Unknown make Unknown", func(t *testing.T) {
|
|
|
|
camera := NewCamera("", "")
|
|
|
|
|
|
|
|
expected := &Camera{
|
|
|
|
CameraModel: "Unknown",
|
|
|
|
CameraMake: "",
|
|
|
|
CameraSlug: "unknown",
|
|
|
|
}
|
|
|
|
assert.Equal(t, expected, camera)
|
|
|
|
})
|
2019-07-16 12:36:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCamera_String(t *testing.T) {
|
|
|
|
t.Run("model XXX make Nikon", func(t *testing.T) {
|
|
|
|
camera := NewCamera("XXX", "Nikon")
|
|
|
|
cameraString := camera.String()
|
|
|
|
assert.Equal(t, "Nikon XXX", cameraString)
|
|
|
|
})
|
|
|
|
t.Run("model XXX make Unknown", func(t *testing.T) {
|
|
|
|
camera := NewCamera("XXX", "")
|
|
|
|
cameraString := camera.String()
|
|
|
|
assert.Equal(t, "XXX", cameraString)
|
|
|
|
})
|
|
|
|
t.Run("model Unkown make Unknown", func(t *testing.T) {
|
|
|
|
camera := NewCamera("", "")
|
|
|
|
cameraString := camera.String()
|
|
|
|
assert.Equal(t, "Unknown", cameraString)
|
|
|
|
})
|
2019-05-03 18:57:28 +02:00
|
|
|
}
|