Files
HackBrowserData/internal/export/format_test.go
T
Roger 2e7ee3c69f test: tidy misplaced, stale, and redundant tests (#691)
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.
2026-11-09 17:25:37 +08:00

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)
}