46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package workspace
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeProjectForCreateAppliesDefaults(t *testing.T) {
|
|
project := NormalizeProjectForCreate(Project{})
|
|
if project.DefaultBranch != DefaultBranch {
|
|
t.Fatalf("default branch = %q", project.DefaultBranch)
|
|
}
|
|
if project.Status != ActiveStatus {
|
|
t.Fatalf("status = %q", project.Status)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeWorkspaceForCreateAppliesDefaults(t *testing.T) {
|
|
ws := NormalizeWorkspaceForCreate(Workspace{Slug: "blog"})
|
|
if ws.BaseBranch != DefaultBranch {
|
|
t.Fatalf("base branch = %q", ws.BaseBranch)
|
|
}
|
|
if ws.WorktreeBranch != "worktree/blog" {
|
|
t.Fatalf("worktree branch = %q", ws.WorktreeBranch)
|
|
}
|
|
if ws.RuntimeBackend != ManagedRuntimeBackend {
|
|
t.Fatalf("runtime backend = %q", ws.RuntimeBackend)
|
|
}
|
|
if ws.Status != ActiveStatus {
|
|
t.Fatalf("status = %q", ws.Status)
|
|
}
|
|
if ws.ProvisionState != PendingProvisionState {
|
|
t.Fatalf("provision state = %q", ws.ProvisionState)
|
|
}
|
|
}
|
|
|
|
func TestApplyManagedRuntimeConfig(t *testing.T) {
|
|
ws := ApplyManagedRuntimeConfig(Workspace{Slug: "blog"}, "/tmp/workspaces", "release")
|
|
if ws.RootPath != "/tmp/workspaces/blog" {
|
|
t.Fatalf("root path = %q", ws.RootPath)
|
|
}
|
|
if ws.BaseBranch != "release" {
|
|
t.Fatalf("base branch = %q", ws.BaseBranch)
|
|
}
|
|
if ws.WorktreeBranch != "worktree/blog" {
|
|
t.Fatalf("worktree branch = %q", ws.WorktreeBranch)
|
|
}
|
|
}
|