-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/tweaks
- Loading branch information
Showing
7 changed files
with
56 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ go.work.sum | |
|
||
# env file | ||
.env | ||
|
||
# jetbrains | ||
.idea/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package gontenttype | ||
|
||
import "testing" | ||
|
||
func TestDetect(t *testing.T) { | ||
type args struct { | ||
content string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want ContentType | ||
}{ | ||
{ | ||
name: "empty", | ||
args: args{content: ""}, | ||
want: Unsupported, | ||
}, | ||
{ | ||
name: "random string defaults to csv", | ||
args: args{content: "lorem ipsum dolor sit amet"}, | ||
want: CSV, | ||
}, | ||
{ | ||
name: "random string with commas, semicolons, tabs, and pipes defaults to csv", | ||
args: args{content: "foo,bar;baz\tqux|quux"}, | ||
want: CSV, | ||
}, | ||
{ | ||
name: "csv comma separated", | ||
args: args{content: "foo,bar\nbaz,qux"}, | ||
want: CSV, | ||
}, | ||
{ | ||
name: "json", | ||
args: args{content: "{\"foo\":\"bar\"}"}, | ||
want: JSON, | ||
}, | ||
{ | ||
name: "xml", | ||
args: args{content: "<foo>bar</foo>"}, | ||
want: XML, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := Detect(tt.args.content); got != tt.want { | ||
t.Errorf("Detect() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |