mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
860b4a8f81
Signed-off-by: Carlos Becker <caarlos0@gmail.com>
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
package project
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
)
|
|
|
|
func TestCustomProjectName(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
ProjectName: "foo",
|
|
Release: config.Release{
|
|
GitHub: config.Repo{
|
|
Owner: "bar",
|
|
Name: "bar",
|
|
},
|
|
},
|
|
})
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.Equal(t, "foo", ctx.Config.ProjectName)
|
|
}
|
|
|
|
func TestEmptyProjectName_DefaultsToGitHubRelease(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Release: config.Release{
|
|
GitHub: config.Repo{
|
|
Owner: "bar",
|
|
Name: "bar",
|
|
},
|
|
},
|
|
})
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.Equal(t, "bar", ctx.Config.ProjectName)
|
|
}
|
|
|
|
func TestEmptyProjectName_DefaultsToGitLabRelease(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Release: config.Release{
|
|
GitLab: config.Repo{
|
|
Owner: "bar",
|
|
Name: "bar",
|
|
},
|
|
},
|
|
})
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.Equal(t, "bar", ctx.Config.ProjectName)
|
|
}
|
|
|
|
func TestEmptyProjectName_DefaultsToGiteaRelease(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Release: config.Release{
|
|
Gitea: config.Repo{
|
|
Owner: "bar",
|
|
Name: "bar",
|
|
},
|
|
},
|
|
})
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.Equal(t, "bar", ctx.Config.ProjectName)
|
|
}
|
|
|
|
func TestEmptyProjectNameAndRelease(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Release: config.Release{
|
|
GitHub: config.Repo{},
|
|
},
|
|
})
|
|
require.EqualError(t, Pipe{}.Default(ctx), "couldn't guess project_name, please add it to your config")
|
|
}
|