Skip to content
Snippets Groups Projects
Select Git revision
  • 8e88b25705bd1be9c1c0e3dd2f938f53a3f2dac2
  • master default protected
  • feature/PRXS-3383-CollectionsRankSortAPI
  • feature/PRXS-3383-CollectionsSort
  • feature/3109-SerializeFeature
  • release/0.33
  • feature/3109-RecoverySchema
  • feature/3109-feature
  • fix/PRXS-3369-ValidateFields
  • refactor/PRXS-3306-MovePkgGroup1
  • refactor/6-pkg-refactor-expr
  • fix/PRXS-3360-TemplateBuilderPatch
  • feature/3293-MongoV2
  • feature/3272-GoVersionUp
  • feature/PRXS-3218-HideTemplateActions
  • feature/PRXS-3234-PruneIdents
  • feature/3146-UpdateItemStorageInterface
  • feature/3274-ObjectIndexesFixes
  • feature/PRXS-3143-3235-ReferenceOptions
  • feature/PRXS-3143-3237-ExecuteOptions
  • feature/3149-LocaleCodeAsID-Implementation
  • v0.33.1
  • v0.32.0
  • v0.31.1
  • v0.31.0
  • v0.30.0
  • v0.29.0
  • v0.28.0
  • v0.27.0-alpha.1+16
  • v0.27.0-alpha.1+15
  • v0.27.0-alpha.1+14
  • v0.27.0-alpha.1+13
  • v0.27.0-alpha.1+12
  • v0.27.0-alpha.1+11
  • v0.27.0-alpha.1+10
  • v0.27.0-alpha.1+9
  • v0.27.0-alpha.1+8
  • v0.27.0-alpha.1+7
  • v0.27.0-alpha.1+6
  • v0.27.0-alpha.1+5
  • v0.27.0-alpha.1+4
41 results

string_test.go

Blame
  • service_test.go 1.43 KiB
    package spaces
    
    import (
    	"context"
    	"testing"
    )
    
    type testSpaces struct {
    	Spaces
    	space *Space
    }
    
    func (t *testSpaces) Get(_ context.Context, spaceID string) (*Space, error) { return t.space, nil }
    
    func TestIsSpaceAvailable(t *testing.T) {
    	tests := []struct {
    		name       string
    		spacesCall *testSpaces
    		spaceId    string
    		wantErr    bool
    	}{
    		{
    			"Without StateInfo",
    			&testSpaces{
    				space: &Space{
    					ID:    "space",
    					OrgID: "org",
    					Name:  "test-space",
    				},
    			},
    			"space",
    			false,
    		},
    		{
    			"StateReady",
    			&testSpaces{
    				space: &Space{
    					ID:        "space",
    					OrgID:     "org",
    					Name:      "test-space",
    					StateInfo: &StateInfo{State: StateReady},
    				},
    			},
    			"space",
    			false,
    		},
    		{
    			"StatePreparing",
    			&testSpaces{
    				space: &Space{
    					ID:        "space",
    					OrgID:     "org",
    					Name:      "test-space",
    					StateInfo: &StateInfo{State: StatePreparing},
    				},
    			},
    			"space",
    			true,
    		},
    		{
    			"StateMigration",
    			&testSpaces{
    				space: &Space{
    					ID:        "space",
    					OrgID:     "org",
    					Name:      "test-space",
    					StateInfo: &StateInfo{State: StateMigration},
    				},
    			},
    			"space",
    			true,
    		},
    	}
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			if err := IsSpaceAvailable(context.Background(), tt.spacesCall, tt.spaceId); (err != nil) != tt.wantErr {
    				t.Errorf("IsSpaceAvailable() error = %v, wantErr %v", err, tt.wantErr)
    			}
    		})
    	}
    }