feat: implement repo create command
This commit is contained in:
parent
73d54fde9c
commit
a43a79d78f
4 changed files with 248 additions and 2 deletions
|
|
@ -219,6 +219,14 @@ func (env *TestEnv) GetLabelIDs(labelNames []string) []int64 {
|
|||
return ids
|
||||
}
|
||||
|
||||
// CleanupRepo deletes a repository created during testing.
|
||||
func (env *TestEnv) CleanupRepo(owner, repoName string) {
|
||||
_, err := env.Client.DeleteRepo(owner, repoName)
|
||||
if err != nil {
|
||||
env.T.Logf("warning: failed to delete repo %s/%s: %v", owner, repoName, err)
|
||||
}
|
||||
}
|
||||
|
||||
// GetBinaryPath returns the path to the built fgj binary
|
||||
func (env *TestEnv) GetBinaryPath() string {
|
||||
binaryPath := os.Getenv("FGJ_BINARY_PATH")
|
||||
|
|
|
|||
|
|
@ -940,3 +940,42 @@ func TestCLIReleaseList(t *testing.T) {
|
|||
|
||||
t.Logf("Successfully listed releases via CLI")
|
||||
}
|
||||
|
||||
// TestCLIRepoCreate verifies `fgj repo create` creates a repository
|
||||
func TestCLIRepoCreate(t *testing.T) {
|
||||
env := NewTestEnv(t)
|
||||
|
||||
repoName := fmt.Sprintf("fgj-test-create-%d", time.Now().UnixNano())
|
||||
defer env.CleanupRepo(env.Owner, repoName)
|
||||
|
||||
result := env.RunCLI(
|
||||
"--hostname", env.Hostname,
|
||||
"repo", "create", repoName,
|
||||
"--public",
|
||||
"-d", "Created by fgj functional test",
|
||||
)
|
||||
|
||||
if result.ExitCode != 0 {
|
||||
t.Fatalf("repo create failed with exit code %d: %s", result.ExitCode, result.Stderr)
|
||||
}
|
||||
|
||||
if !bytes.Contains([]byte(result.Stdout), []byte(repoName)) {
|
||||
t.Fatalf("expected output to contain repo name %q, got: %s", repoName, result.Stdout)
|
||||
}
|
||||
|
||||
repo, _, err := env.Client.GetRepo(env.Owner, repoName)
|
||||
if err != nil {
|
||||
t.Fatalf("repo was not created or not accessible: %v", err)
|
||||
}
|
||||
if repo.Name != repoName {
|
||||
t.Fatalf("expected repo name %q, got %q", repoName, repo.Name)
|
||||
}
|
||||
if repo.Private {
|
||||
t.Fatalf("expected public repo, got private")
|
||||
}
|
||||
if repo.Description != "Created by fgj functional test" {
|
||||
t.Fatalf("expected description %q, got %q", "Created by fgj functional test", repo.Description)
|
||||
}
|
||||
|
||||
t.Logf("Successfully created repository %s via CLI", repo.FullName)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue