Fix review

This commit is contained in:
Theodor S. Midtlien
2026-06-02 15:43:45 +02:00
parent e27f0ed05b
commit 75a898869f
6 changed files with 8 additions and 17 deletions

View File

@@ -213,10 +213,10 @@ func (pm *ProfileManager) getProfileConfigPath(id string) (string, error) {
return filepath.Join(profilesDir, id+".json"), nil
}
// GetConfigPath returns the config file path for a given profile
// GetConfigPath returns the config file path for a given profile id
// Java should call this instead of constructing paths with Preferences.configFile()
func (pm *ProfileManager) GetConfigPath(profileName string) (string, error) {
return pm.getProfileConfigPath(profileName)
func (pm *ProfileManager) GetConfigPath(id string) (string, error) {
return pm.getProfileConfigPath(id)
}
// GetStateFilePath returns the state file path for a given profile

View File

@@ -171,7 +171,7 @@ func getActiveProfile(ctx context.Context, pm *profilemanager.ProfileManager, pr
}
func switchProfileOnDaemon(ctx context.Context, pm *profilemanager.ProfileManager, handle string, username string) error {
resolvedID, err := switchProfile(context.Background(), handle, username)
resolvedID, err := switchProfile(ctx, handle, username)
if err != nil {
return fmt.Errorf("switch profile on daemon: %v", err)
}

View File

@@ -843,6 +843,7 @@ func TestAddConfig_AllFieldsCovered(t *testing.T) {
"PreSharedKey": "sensitive: WireGuard pre-shared key",
"SSHKey": "sensitive: SSH private key",
"ClientCertKeyPair": "non-config: parsed cert pair, not serialized",
"Name": "non-config: profile name is not needed for debug purposes",
}
mURL, _ := url.Parse("https://api.example.com:443")

View File

@@ -442,7 +442,7 @@ func (s *ServiceManager) loadAllProfiles(username string) ([]Profile, error) {
ID: defaultProfileName,
Name: defaultProfileName,
Path: DefaultConfigPath,
IsActive: activeIsDefault || activeID == defaultProfileName,
IsActive: activeIsDefault,
}}
configDir, err := s.getConfigDir(username)
@@ -487,7 +487,7 @@ func (s *ServiceManager) loadAllProfiles(username string) ([]Profile, error) {
ID: stem,
Name: name,
Path: path,
IsActive: stem == activeID && !activeIsDefault,
IsActive: stem == activeID,
})
}

View File

@@ -131,16 +131,6 @@ func TestServiceProfile_LegacyFilenameCoexists(t *testing.T) {
})
}
func TestAddProfile_RejectsDuplicateNameByDefault(t *testing.T) {
withTestSM(t, func(sm *ServiceManager, username string) {
_, err := sm.AddProfile("work", username)
require.NoError(t, err)
_, err = sm.AddProfile("work", username)
assert.ErrorIs(t, err, ErrProfileAlreadyExists)
})
}
func TestAddProfile_AllowsDuplicateWithFlag(t *testing.T) {
withTestSM(t, func(sm *ServiceManager, username string) {
first, err := sm.AddProfile("work", username)

View File

@@ -493,7 +493,7 @@ func (s *serviceClient) getConnectionForm() *widget.Form {
if err != nil {
log.Errorf("get active profile: %v", err)
} else {
activeProfName = activeProf.ID
activeProfName = activeProf.Name
}
return &widget.Form{
Items: []*widget.FormItem{