Skip to content
Snippets Groups Projects
Select Git revision
  • 13e7fa033da521c5a778dbd4df050d670e2bbab5
  • 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

mongo_test.go

Blame
  • service_test.go 1.42 KiB
    package spaces
    
    import (
    	"context"
    	"testing"
    )
    
    // dummySpaces используется для имитации поведения Spaces
    // Моки использовать не можем, так как получается циклический импорт
    type dummySpaces struct {
    	Spaces
    	space *Space
    }
    
    func (t *dummySpaces) Get(_ context.Context, _ string) (*Space, error) { return t.space, nil }
    
    func TestIsSpaceAvailable(t *testing.T) {
    	tests := []struct {
    		name    string
    		space   *Space
    		wantErr bool
    	}{
    		{
    			"Space has nil StateInfo: available",
    			&Space{ID: "space", OrgID: "org", Name: "test-space"},
    			false,
    		},
    		{
    			"Space state is StateReady: available",
    			&Space{ID: "space", OrgID: "org", Name: "test-space", StateInfo: &StateInfo{State: StateReady}},
    			false,
    		},
    		{
    			"Space state is StatePreparing: not available",
    			&Space{ID: "space", OrgID: "org", Name: "test-space", StateInfo: &StateInfo{State: StatePreparing}},
    			true,
    		},
    		{
    			"Space state is StateMigration: not available",
    			&Space{ID: "space", OrgID: "org", Name: "test-space", StateInfo: &StateInfo{State: StateMigration}},
    			true,
    		},
    	}
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			spaces := &dummySpaces{space: tt.space}
    			if err := IsSpaceAvailable(context.Background(), spaces, "space"); (err != nil) != tt.wantErr {
    				t.Errorf("IsSpaceAvailable() error = %v, wantErr %v", err, tt.wantErr)
    			}
    		})
    	}
    }