1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

test: add first few unit tests

This commit is contained in:
Ferdinand Mütsch
2020-11-08 12:46:12 +01:00
parent 35cdc7b485
commit ad8168801c
17 changed files with 519 additions and 11 deletions

View File

@ -2,10 +2,11 @@ package utils
import (
"errors"
"github.com/stretchr/testify/assert"
"testing"
)
func TestParseUserAgent(t *testing.T) {
func TestCommon_ParseUserAgent(t *testing.T) {
tests := []struct {
in string
outOs string
@ -38,10 +39,11 @@ func TestParseUserAgent(t *testing.T) {
},
}
for i, test := range tests {
if os, editor, err := ParseUserAgent(test.in); os != test.outOs || editor != test.outEditor || !checkErr(test.outError, err) {
t.Errorf("[%d] Unexpected result of parsing '%s'; got '%v', '%v', '%v'", i, test.in, os, editor, err)
}
for _, test := range tests {
os, editor, err := ParseUserAgent(test.in)
assert.True(t, checkErr(err, test.outError))
assert.Equal(t, test.outOs, os)
assert.Equal(t, test.outEditor, editor)
}
}