-
Notifications
You must be signed in to change notification settings - Fork 1
/
artifact_test.go
45 lines (37 loc) · 1.11 KB
/
artifact_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
package cask
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewArtifact(t *testing.T) {
// preparations
a := NewArtifact(ArtifactApp, "value")
// test
assert.IsType(t, Artifact{}, *a)
assert.Equal(t, ArtifactApp, a.Type)
assert.Equal(t, "value", a.Value)
assert.Empty(t, a.Target)
assert.False(t, a.AllowUntrusted)
}
func TestArtifactTypeString(t *testing.T) {
assert.Equal(t, "app", ArtifactApp.String())
assert.Equal(t, "pkg", ArtifactPkg.String())
assert.Equal(t, "binary", ArtifactBinary.String())
}
func TestArtifactString(t *testing.T) {
// app
a := NewArtifact(ArtifactApp, "Test.app")
assert.Equal(t, "app, Test.app", a.String())
a.Target = "Target.app"
assert.Equal(t, "app, Test.app => Target.app", a.String())
// pkg
a = NewArtifact(ArtifactPkg, "test.pkg")
assert.Equal(t, "pkg, test.pkg", a.String())
a.AllowUntrusted = true
assert.Equal(t, "pkg, test.pkg, allow_untrusted: true", a.String())
// binary
a = NewArtifact(ArtifactBinary, "test")
assert.Equal(t, "binary, test", a.String())
a.Target = "target"
assert.Equal(t, "binary, test => target", a.String())
}