Backend: Add tests to internal/entity
This commit is contained in:
parent
2c564ed145
commit
156c7b295e
4 changed files with 108 additions and 2 deletions
|
@ -27,7 +27,7 @@ var FileShareFixtures = FileShareMap{
|
|||
FileID: 1000000,
|
||||
AccountID: 1000000,
|
||||
RemoteName: "name for remote",
|
||||
Status: "test",
|
||||
Status: FileShareShared,
|
||||
Error: "",
|
||||
Errors: 0,
|
||||
File: nil,
|
||||
|
@ -39,7 +39,7 @@ var FileShareFixtures = FileShareMap{
|
|||
FileID: 1000000,
|
||||
AccountID: 1000001,
|
||||
RemoteName: "name for remote",
|
||||
Status: "test",
|
||||
Status: FileShareNew,
|
||||
Error: "",
|
||||
Errors: 0,
|
||||
File: nil,
|
||||
|
|
36
internal/entity/file_share_fixtures_test.go
Normal file
36
internal/entity/file_share_fixtures_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFileShareMap_Get(t *testing.T) {
|
||||
t.Run("get existing fileshare", func(t *testing.T) {
|
||||
r := FileShareFixtures.Get("FileShare1", 0, 0, "")
|
||||
assert.Equal(t, uint(1000000), r.AccountID)
|
||||
assert.Equal(t, "name for remote", r.RemoteName)
|
||||
assert.IsType(t, FileShare{}, r)
|
||||
})
|
||||
t.Run("get not existing fileshare", func(t *testing.T) {
|
||||
r := FileShareFixtures.Get("FileShareXXX", 123, 888, "new remote name")
|
||||
assert.Equal(t, uint(888), r.AccountID)
|
||||
assert.Equal(t, "new remote name", r.RemoteName)
|
||||
assert.IsType(t, FileShare{}, r)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFileShareMap_Pointer(t *testing.T) {
|
||||
t.Run("get existing fileshare pointer", func(t *testing.T) {
|
||||
r := FileShareFixtures.Pointer("FileShare1", 0, 0, "")
|
||||
assert.Equal(t, uint(1000000), r.AccountID)
|
||||
assert.Equal(t, "name for remote", r.RemoteName)
|
||||
assert.IsType(t, &FileShare{}, r)
|
||||
})
|
||||
t.Run("get not existing fileshare pointer", func(t *testing.T) {
|
||||
r := FileShareFixtures.Pointer("FileShareYYY", 456, 889, "new remote name for pointer")
|
||||
assert.Equal(t, uint(889), r.AccountID)
|
||||
assert.Equal(t, "new remote name for pointer", r.RemoteName)
|
||||
assert.IsType(t, &FileShare{}, r)
|
||||
})
|
||||
}
|
36
internal/entity/file_sync_fixtures_test.go
Normal file
36
internal/entity/file_sync_fixtures_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFileSyncMap_Get(t *testing.T) {
|
||||
t.Run("get existing filesync", func(t *testing.T) {
|
||||
r := FileSyncFixtures.Get("FileSync1", 0, "")
|
||||
assert.Equal(t, uint(1000000), r.AccountID)
|
||||
assert.Equal(t, "name for remote sync", r.RemoteName)
|
||||
assert.IsType(t, FileSync{}, r)
|
||||
})
|
||||
t.Run("get not existing filesync", func(t *testing.T) {
|
||||
r := FileSyncFixtures.Get("FileSyncXXX", 123, "new remote name for sync")
|
||||
assert.Equal(t, uint(123), r.AccountID)
|
||||
assert.Equal(t, "new remote name for sync", r.RemoteName)
|
||||
assert.IsType(t, FileSync{}, r)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFileSyncMap_Pointer(t *testing.T) {
|
||||
t.Run("get existing filesync pointer", func(t *testing.T) {
|
||||
r := FileSyncFixtures.Pointer("FileSync1", 0, "")
|
||||
assert.Equal(t, uint(1000000), r.AccountID)
|
||||
assert.Equal(t, "name for remote sync", r.RemoteName)
|
||||
assert.IsType(t, &FileSync{}, r)
|
||||
})
|
||||
t.Run("get not existing filesync pointer", func(t *testing.T) {
|
||||
r := FileSyncFixtures.Pointer("FileSyncYYY", 456, "new remote name for sync pointer")
|
||||
assert.Equal(t, uint(456), r.AccountID)
|
||||
assert.Equal(t, "new remote name for sync pointer", r.RemoteName)
|
||||
assert.IsType(t, &FileSync{}, r)
|
||||
})
|
||||
}
|
34
internal/entity/lens_fixtures_test.go
Normal file
34
internal/entity/lens_fixtures_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLensMap_Get(t *testing.T) {
|
||||
t.Run("get existing lens", 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) {
|
||||
r := LensFixtures.Get("Lens 123")
|
||||
assert.Equal(t, "lens-123", r.LensSlug)
|
||||
assert.IsType(t, Lens{}, r)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLensMap_Pointer(t *testing.T) {
|
||||
t.Run("get existing lens pointer", 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) {
|
||||
r := LensFixtures.Pointer("Lens new")
|
||||
assert.Equal(t, "lens-new", r.LensSlug)
|
||||
assert.IsType(t, &Lens{}, r)
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue