Merge branch 'develop'

# Conflicts:
#	frontend/src/pages/places.vue
This commit is contained in:
Michael Mayer 2019-12-17 17:19:07 +01:00
commit 098d8e9493
5 changed files with 78 additions and 2 deletions

View file

@ -130,11 +130,11 @@
const changed = Math.abs(this.query.lat - pos.lat) > 0.001 ||
Math.abs(this.query.long - pos.lng) > 0.001;
if(!changed) return;
this.query.lat = pos.lat.toString();
this.query.long = pos.lng.toString();
if(!changed) return;
this.search();
},
startPos() {

View file

@ -0,0 +1,18 @@
package util
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestKeywords(t *testing.T) {
t.Run("cat", func(t *testing.T) {
keywords := Keywords("cat")
assert.Equal(t, []string{"cat"}, keywords)
})
t.Run("was", func(t *testing.T) {
keywords := Keywords("was")
assert.Equal(t, []string(nil), keywords)
})
}

View file

@ -0,0 +1,20 @@
package util
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMimeType(t *testing.T) {
t.Run("jpg", func(t *testing.T) {
filename := ExpandedFilename("./testdata/test.jpg")
mimeType := MimeType(filename)
assert.Equal(t, "image/jpeg", mimeType)
})
t.Run("not existing filename", func(t *testing.T) {
filename := ExpandedFilename("./testdata/xxx.jpg")
mimeType := MimeType(filename)
assert.Equal(t, "", mimeType)
})
}

View file

@ -6,6 +6,15 @@ import (
"github.com/stretchr/testify/assert"
)
func TestContainsNumber(t *testing.T) {
t.Run("True", func(t *testing.T) {
assert.Equal(t, true, ContainsNumber("f3abcde"))
})
t.Run("False", func(t *testing.T) {
assert.Equal(t, false, ContainsNumber("abcd"))
})
}
func TestIsSeparator(t *testing.T) {
t.Run("rune A", func(t *testing.T) {
assert.Equal(t, false, isSeparator('A'))

View file

@ -0,0 +1,29 @@
package util
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRandomToken(t *testing.T) {
t.Run("size 4", func(t *testing.T) {
token := RandomToken(4)
assert.NotEmpty(t, token)
})
t.Run("size 8", func(t *testing.T) {
token := RandomToken(9)
assert.NotEmpty(t, token)
})
}
func TestUUID(t *testing.T) {
t.Run("size 4", func(t *testing.T) {
uuid := UUID()
assert.Equal(t, 36, len(uuid))
})
t.Run("size 8", func(t *testing.T) {
uuid := UUID()
assert.Equal(t, 36, len(uuid))
})
}