MCPcopy Create free account
hub / github.com/go-task/task / TestPlatformParsing

Function TestPlatformParsing

taskfile/ast/platforms_test.go:10–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestPlatformParsing(t *testing.T) {
11 t.Parallel()
12
13 tests := []struct {
14 Input string
15 ExpectedOS string
16 ExpectedArch string
17 Error string
18 }{
19 {Input: "windows", ExpectedOS: "windows", ExpectedArch: ""},
20 {Input: "linux", ExpectedOS: "linux", ExpectedArch: ""},
21 {Input: "darwin", ExpectedOS: "darwin", ExpectedArch: ""},
22
23 {Input: "386", ExpectedOS: "", ExpectedArch: "386"},
24 {Input: "amd64", ExpectedOS: "", ExpectedArch: "amd64"},
25 {Input: "arm64", ExpectedOS: "", ExpectedArch: "arm64"},
26
27 {Input: "windows/386", ExpectedOS: "windows", ExpectedArch: "386"},
28 {Input: "windows/amd64", ExpectedOS: "windows", ExpectedArch: "amd64"},
29 {Input: "windows/arm64", ExpectedOS: "windows", ExpectedArch: "arm64"},
30
31 {Input: "invalid", Error: `invalid platform "invalid"`},
32 {Input: "invalid/invalid", Error: `invalid platform "invalid/invalid"`},
33 {Input: "windows/invalid", Error: `invalid platform "windows/invalid"`},
34 {Input: "invalid/amd64", Error: `invalid platform "invalid/amd64"`},
35 }
36
37 for _, test := range tests {
38 t.Run(test.Input, func(t *testing.T) {
39 t.Parallel()
40
41 var p Platform
42 err := p.parsePlatform(test.Input)
43
44 if test.Error != "" {
45 require.Error(t, err)
46 assert.Equal(t, test.Error, err.Error())
47 } else {
48 require.NoError(t, err)
49 assert.Equal(t, test.ExpectedOS, p.OS)
50 assert.Equal(t, test.ExpectedArch, p.Arch)
51 }
52 })
53 }
54}

Callers

nothing calls this directly

Calls 3

parsePlatformMethod · 0.95
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…