forked from docker-exec/dexec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dexec_test.go
63 lines (60 loc) · 1.85 KB
/
dexec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import "testing"
func TestExtractFileExtension(t *testing.T) {
cases := []struct {
filename string
extension string
}{
{"foo.bar", "bar"},
{"foo.bar.foobar", "foobar"},
}
for _, c := range cases {
gotExtension := ExtractFileExtension(c.filename)
if gotExtension != c.extension {
t.Errorf("ExtractFileExtension %q != %q", gotExtension, c.extension)
}
}
}
func TestLookupImageByExtension(t *testing.T) {
cases := []struct {
extension string
wantExtension string
wantImage string
wantVersion string
}{
{"c", "c", "c", "1.0.0"},
{"clj", "clj", "clojure", "1.0.0"},
{"coffee", "coffee", "coffee", "1.0.0"},
{"cpp", "cpp", "cpp", "1.0.0"},
{"cs", "cs", "csharp", "1.0.0"},
{"d", "d", "d", "1.0.0"},
{"erl", "erl", "erlang", "1.0.0"},
{"fs", "fs", "fsharp", "1.0.0"},
{"go", "go", "go", "1.0.0"},
{"groovy", "groovy", "groovy", "1.0.0"},
{"hs", "hs", "haskell", "1.0.0"},
{"java", "java", "java", "1.0.0"},
{"lisp", "lisp", "lisp", "1.0.0"},
{"js", "js", "node", "1.0.0"},
{"m", "m", "objc", "1.0.0"},
{"ml", "ml", "ocaml", "1.0.0"},
{"pl", "pl", "perl", "1.0.0"},
{"php", "php", "php", "1.0.0"},
{"py", "py", "python", "1.0.0"},
{"rkt", "rkt", "racket", "1.0.0"},
{"rb", "rb", "ruby", "1.0.0"},
{"rs", "rs", "rust", "1.0.0"},
{"scala", "scala", "scala", "1.0.0"},
{"sh", "sh", "bash", "1.0.0"},
}
for _, c := range cases {
got := LookupImageByExtension(c.extension)
if got.extension != c.wantExtension {
t.Errorf("TestLookupExtensionByImage(%q) %q != %q", c.extension, got.image, c.wantImage)
} else if got.extension != c.wantExtension {
t.Errorf("TestLookupExtensionByImage(%q) %q != %q", c.extension, got.extension, c.wantExtension)
} else if got.version != c.wantVersion {
t.Errorf("TestLookupExtensionByImage(%q) %q != %q", c.extension, got.version, c.wantVersion)
}
}
}