mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
test: fixed snap tests
This commit is contained in:
parent
a751da5909
commit
12321ec0e8
@ -46,19 +46,16 @@ func TestRunPipe(t *testing.T) {
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, err)
|
||||
var ctx = &context.Context{
|
||||
Version: "testversion",
|
||||
Artifacts: artifact.New(),
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
},
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
},
|
||||
}
|
||||
})
|
||||
ctx.Version = "testversion"
|
||||
addBinaries(t, ctx, "mybin", dist)
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
}
|
||||
@ -69,19 +66,16 @@ func TestRunPipeInvalidNameTemplate(t *testing.T) {
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, err)
|
||||
var ctx = &context.Context{
|
||||
Version: "testversion",
|
||||
Artifacts: artifact.New(),
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
},
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
},
|
||||
}
|
||||
})
|
||||
ctx.Version = "testversion"
|
||||
addBinaries(t, ctx, "mybin", dist)
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `template: foo_{{.Arch}:1: unexpected "}" in operand`)
|
||||
}
|
||||
@ -92,20 +86,17 @@ func TestRunPipeWithName(t *testing.T) {
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, err)
|
||||
var ctx = &context.Context{
|
||||
Version: "testversion",
|
||||
Artifacts: artifact.New(),
|
||||
Config: config.Project{
|
||||
ProjectName: "testprojectname",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}}",
|
||||
Name: "testsnapname",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
},
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "testprojectname",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}}",
|
||||
Name: "testsnapname",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
},
|
||||
}
|
||||
})
|
||||
ctx.Version = "testversion"
|
||||
addBinaries(t, ctx, "testprojectname", dist)
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
yamlFile, err := ioutil.ReadFile(filepath.Join(dist, "foo_amd64", "prime", "meta", "snap.yaml"))
|
||||
@ -122,25 +113,22 @@ func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, err)
|
||||
var ctx = &context.Context{
|
||||
Version: "testversion",
|
||||
Artifacts: artifact.New(),
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
Apps: map[string]config.SnapcraftAppMetadata{
|
||||
"mybin": {
|
||||
Plugs: []string{"home", "network"},
|
||||
Daemon: "simple",
|
||||
},
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Snapcraft: config.Snapcraft{
|
||||
NameTemplate: "foo_{{.Arch}}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
Apps: map[string]config.SnapcraftAppMetadata{
|
||||
"mybin": {
|
||||
Plugs: []string{"home", "network"},
|
||||
Daemon: "simple",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
ctx.Version = "testversion"
|
||||
addBinaries(t, ctx, "mybin", dist)
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
yamlFile, err := ioutil.ReadFile(filepath.Join(dist, "foo_amd64", "prime", "meta", "snap.yaml"))
|
||||
@ -158,14 +146,12 @@ func TestNoSnapcraftInPath(t *testing.T) {
|
||||
assert.NoError(t, os.Setenv("PATH", path))
|
||||
}()
|
||||
assert.NoError(t, os.Setenv("PATH", ""))
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
Snapcraft: config.Snapcraft{
|
||||
Summary: "dummy",
|
||||
Description: "dummy",
|
||||
},
|
||||
var ctx = context.New(config.Project{
|
||||
Snapcraft: config.Snapcraft{
|
||||
Summary: "dummy",
|
||||
Description: "dummy",
|
||||
},
|
||||
}
|
||||
})
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), ErrNoSnapcraft.Error())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user