aboutsummaryrefslogtreecommitdiff
path: root/classifier_test.go
diff options
context:
space:
mode:
authorRobert Spier <rspier@google.com>2019-05-01 14:26:18 -0700
committerRobert Spier <rspier@google.com>2019-05-01 14:26:18 -0700
commit47b603fe1b8cf823b1227e0573cc620bf929a63b (patch)
tree34a16b8a3d149d81647d8572b457d1f37cd9cd28 /classifier_test.go
parent57ecb7c44031f8d66cc9316e6e51e9303c65d9e5 (diff)
downloadlicenseclassifier-47b603fe1b8cf823b1227e0573cc620bf929a63b.tar.gz
Revert "Benchmark for diagnosing license classifier performance problems."
This reverts commit 57ecb7c44031f8d66cc9316e6e51e9303c65d9e5. It was pushed accidentally and overwote changes.
Diffstat (limited to 'classifier_test.go')
-rw-r--r--classifier_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/classifier_test.go b/classifier_test.go
index 7ba32e6..b997a35 100644
--- a/classifier_test.go
+++ b/classifier_test.go
@@ -797,3 +797,41 @@ func BenchmarkClassifier(b *testing.B) {
classifier.NearestMatch(contents)
}
}
+
+func TestNew(t *testing.T) {
+ tests := []struct {
+ desc string
+ options []OptionFunc
+ wantArchive string
+ wantErr bool
+ }{
+ {
+ desc: "no options, use default",
+ options: []OptionFunc{},
+ wantArchive: LicenseArchive,
+ },
+ {
+ desc: "specify ForbiddenLicenseArchive",
+ options: []OptionFunc{Archive(ForbiddenLicenseArchive)},
+ wantArchive: ForbiddenLicenseArchive,
+ },
+ {
+ desc: "file doesn't exist results in error",
+ options: []OptionFunc{Archive("doesnotexist")},
+ wantArchive: "doesnotexist",
+ wantErr: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.desc, func(t *testing.T) {
+ c, err := New(0.5, tt.options...)
+ if tt.wantErr != (err != nil) {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if err == nil && c.archive != tt.wantArchive {
+ t.Errorf("got archive %v, want %v", c.archive, tt.wantArchive)
+ }
+ })
+ }
+
+}