Tests: Add unit tests
This commit is contained in:
parent
5bd822e616
commit
d6ba514922
2 changed files with 60 additions and 4 deletions
|
@ -7,13 +7,43 @@ import (
|
|||
)
|
||||
|
||||
func TestGrant_Allow(t *testing.T) {
|
||||
t.Run("ViewAllDownload", func(t *testing.T) {
|
||||
assert.True(t, GrantViewAll.Allow(ActionView))
|
||||
t.Run("GrantFullAccessAll", func(t *testing.T) {
|
||||
assert.True(t, GrantFullAccess.Allow(AccessAll))
|
||||
})
|
||||
t.Run("ViewAllShare", func(t *testing.T) {
|
||||
assert.False(t, GrantViewAll.Allow(ActionShare))
|
||||
t.Run("GrantFullAccessDownload", func(t *testing.T) {
|
||||
assert.True(t, GrantFullAccess.Allow(ActionDownload))
|
||||
})
|
||||
t.Run("GrantFullAccessDelete", func(t *testing.T) {
|
||||
assert.True(t, GrantFullAccess.Allow(ActionDelete))
|
||||
})
|
||||
t.Run("GrantFullAccessLibrary", func(t *testing.T) {
|
||||
assert.True(t, GrantFullAccess.Allow(AccessLibrary))
|
||||
})
|
||||
t.Run("UnknownAction", func(t *testing.T) {
|
||||
assert.False(t, GrantViewAll.Allow("lovecats"))
|
||||
})
|
||||
t.Run("ViewAllView", func(t *testing.T) {
|
||||
assert.True(t, GrantViewAll.Allow(ActionView))
|
||||
})
|
||||
t.Run("ViewAllAccessAll", func(t *testing.T) {
|
||||
assert.True(t, GrantViewAll.Allow(AccessAll))
|
||||
})
|
||||
t.Run("ViewAllDownload", func(t *testing.T) {
|
||||
assert.False(t, GrantViewAll.Allow(ActionDownload))
|
||||
})
|
||||
t.Run("ViewAllShare", func(t *testing.T) {
|
||||
assert.False(t, GrantViewAll.Allow(ActionShare))
|
||||
})
|
||||
t.Run("ViewOwnShare", func(t *testing.T) {
|
||||
assert.False(t, GrantViewOwn.Allow(ActionShare))
|
||||
})
|
||||
t.Run("ViewOwnView", func(t *testing.T) {
|
||||
assert.True(t, GrantViewOwn.Allow(ActionView))
|
||||
})
|
||||
t.Run("ViewOwnAccessAll", func(t *testing.T) {
|
||||
assert.False(t, GrantViewOwn.Allow(AccessAll))
|
||||
})
|
||||
t.Run("ViewOwnAccessOwn", func(t *testing.T) {
|
||||
assert.True(t, GrantViewOwn.Allow(AccessOwn))
|
||||
})
|
||||
}
|
||||
|
|
26
internal/commands/find_test.go
Normal file
26
internal/commands/find_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"github.com/photoprism/photoprism/pkg/capture"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFindCommand(t *testing.T) {
|
||||
t.Run("All", func(t *testing.T) {
|
||||
var err error
|
||||
|
||||
// Create test context with flags and arguments.
|
||||
ctx := NewTestContext([]string{"find", "--csv"})
|
||||
|
||||
// Run command with test context.
|
||||
output := capture.Output(func() {
|
||||
err = FindCommand.Run(ctx)
|
||||
})
|
||||
|
||||
// Check command output for plausibility.
|
||||
//t.Logf(output)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, output, "File Name;Mime Type;")
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue