mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Tests now sit beside the code they cover; ones a golden or another test already pins are gone, and core tests gain the assertions a real regression would trip.
32 lines
615 B
Go
32 lines
615 B
Go
package export
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestParseFormat(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want Format
|
|
}{
|
|
{"json", JSON},
|
|
{"csv", CSV},
|
|
{"cookie-editor", CookieEditor},
|
|
}
|
|
for _, testCase := range tests {
|
|
got, err := ParseFormat(testCase.input)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, testCase.want, got)
|
|
}
|
|
_, err := ParseFormat("unknown")
|
|
require.EqualError(t, err, "unsupported format: unknown")
|
|
}
|
|
|
|
func TestFormat_ZeroIsJSON(t *testing.T) {
|
|
var format Format
|
|
assert.Equal(t, JSON, format)
|
|
}
|