Skip to content

fix(config): fix deletion of profiles on some systems#1389

Open
Manuelvaas wants to merge 1 commit intomainfrom
bugfix/delete-profiles
Open

fix(config): fix deletion of profiles on some systems#1389
Manuelvaas wants to merge 1 commit intomainfrom
bugfix/delete-profiles

Conversation

@Manuelvaas
Copy link
Copy Markdown
Contributor

Description

relates to STACKITCLI-389

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see e.g. here)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@Manuelvaas Manuelvaas requested a review from a team as a code owner April 28, 2026 10:18
@github-actions
Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/config/profile/delete 27.03% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/config/profile/delete/delete.go 27.03% (ø) 37 10 27

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@cgoetz-inovex
Copy link
Copy Markdown
Contributor

regarding testing:

// regression test for STACKITCLI-389
func TestDeleteProfileWithoutKeyring(t *testing.T) {
	params := testparams.NewTestParams()
	params.Printer.AssumeYes = true
	profile := fmt.Sprintf("test-profile-%s", time.Now().Format("20060102150405"))
	path := config.GetProfileFolderPath(profile)
	t.Cleanup(func() {
		err := os.RemoveAll(path)
		if err != nil {
			t.Fatalf("cleanup: remove profile folder at path %q: %v", path, err)
		}
	})
	err := config.ValidateProfile(profile)
	if err != nil {
		t.Fatalf("validate profile %q: %v", profile, err)
	}
	err = config.CreateProfile(params.Printer, profile, true, false, true)
	if err != nil {
		t.Fatalf("create profile %q: %v", profile, err)
	}
	keyring.MockInitWithError(keyring.ErrUnsupportedPlatform)
	deleteCmd := NewCmd(params.CmdParams)
	err = deleteCmd.RunE(deleteCmd, []string{profile})
	if err != nil {
		t.Fatalf("run cmd: %v", err)
	}
	if _, err := os.Stat(path); !os.IsNotExist(err) {
		t.Fatalf("expected profile folder to be deleted, but it still exists at path %q", path)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants