-
Notifications
You must be signed in to change notification settings - Fork 17
/
plugin_test.go
56 lines (53 loc) · 1.34 KB
/
plugin_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
package main
import (
"os"
"strings"
"testing"
)
func TestPublish(t *testing.T) {
repository := os.Getenv("PLUGIN_REPOSITORY")
username := os.Getenv("PLUGIN_USERNAME")
password := os.Getenv("PLUGIN_PASSWORD")
plugin := Plugin{
Repository: repository,
Username: username,
Password: password,
SetupFile: "testdata/setup.py",
Distributions: strings.Split(os.Getenv("PLUGIN_DISTRIBUTIONS"), " "),
SkipBuild: false,
DistDir: "dist/",
}
err := plugin.Exec()
if err != nil {
t.Error(err)
}
}
// TestUpload checks if a distutils upload command can be properly
// generated and formatted.
func TestUpload(t *testing.T) {
testdata := []struct {
distributions []string
exp []string
}{
{
[]string{},
[]string{"python3", "testdata/setup.py", "sdist"},
},
{
[]string{"sdist", "bdist_wheel"},
[]string{"python3", "testdata/setup.py", "sdist", "bdist_wheel"},
},
}
for i, data := range testdata {
p := Plugin{Distributions: data.distributions, SetupFile: "testdata/setup.py"}
c := p.buildCommand()
if len(c.Args) != len(data.exp) {
t.Errorf("Case %d: Expected %d, got %d", i, len(data.exp), len(c.Args))
}
for i := range c.Args {
if c.Args[i] != data.exp[i] {
t.Errorf("Case %d: Expected %s, got %s", i, strings.Join(data.exp, " "), strings.Join(c.Args, " "))
}
}
}
}