Skip to content

Commit

Permalink
Rename switch to set in the config context store
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar committed Oct 12, 2023
1 parent dfe35ae commit 3a25fef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions contexts-config-store/store/contexts_config_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type ContextsConfigStore interface {
// GetCurrentContext returns the current context information.
GetCurrentContext() (*generated.KurtosisContext, error)

// SwitchContext switches to the context passed as an argument.
// SetContext switches to the context passed as an argument.
// It throws an error if the contextUuid does not point to any known context.
SwitchContext(contextUuid *generated.ContextUuid) error
SetContext(contextUuid *generated.ContextUuid) error

// AddNewContext adds a new context to the store.
// It throws an error if a context with the same UUID already exists
Expand Down
2 changes: 1 addition & 1 deletion contexts-config-store/store/contexts_config_store_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (store *contextConfigStoreImpl) GetCurrentContext() (*generated.KurtosisCon
strings.Join(contextUuidsInStore, contextUuidsSeparator))
}

func (store *contextConfigStoreImpl) SwitchContext(contextUuid *generated.ContextUuid) error {
func (store *contextConfigStoreImpl) SetContext(contextUuid *generated.ContextUuid) error {
store.Lock()
defer store.Unlock()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestGetCurrentContext_failureInconsistentContextConfig(t *testing.T) {
require.Nil(t, result)
}

func TestSwitchContext(t *testing.T) {
func TestSetContext(t *testing.T) {
// Setup storage mock
storage := persistence.NewMockConfigPersistence(t)
contextsConfig := api.NewKurtosisContextsConfig(contextUuid, localContext, otherLocalContext)
Expand All @@ -79,19 +79,19 @@ func TestSwitchContext(t *testing.T) {

// Run test
testContextConfigStore := NewContextConfigStore(storage)
err := testContextConfigStore.SwitchContext(otherContextUuid)
err := testContextConfigStore.SetContext(otherContextUuid)
require.NoError(t, err)
}

func TestSwitchContext_NonExistingContextFailure(t *testing.T) {
func TestSetContext_NonExistingContextFailure(t *testing.T) {
// Setup storage mock
storage := persistence.NewMockConfigPersistence(t)
contextsConfig := api.NewKurtosisContextsConfig(contextUuid, localContext)
storage.EXPECT().LoadContextsConfig().Return(contextsConfig, nil)

// Run test
testContextConfigStore := NewContextConfigStore(storage)
err := testContextConfigStore.SwitchContext(otherContextUuid)
err := testContextConfigStore.SetContext(otherContextUuid)
require.Error(t, err)
expectedErr := fmt.Sprintf("Context with UUID '%s' does not exist in store. Known contexts are: '%s'",
otherContextUuid.GetValue(), contextUuid.GetValue())
Expand Down
20 changes: 10 additions & 10 deletions contexts-config-store/store/mock_contexts_config_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a25fef

Please sign in to comment.