github.com/weaviate/weaviate@v1.24.6/entities/storagestate/status_test.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package storagestate
    13  
    14  import (
    15  	"testing"
    16  
    17  	"github.com/stretchr/testify/require"
    18  )
    19  
    20  func TestStatusValidation(t *testing.T) {
    21  	t.Run("with invalid status", func(t *testing.T) {
    22  		tests := []string{
    23  			"READ_ONLY",
    24  			"read only",
    25  			"ok",
    26  			"WRITEONLY",
    27  			"INDESKING",
    28  			"",
    29  		}
    30  
    31  		for _, test := range tests {
    32  			_, err := ValidateStatus(test)
    33  			require.EqualError(t, ErrInvalidStatus, err.Error())
    34  		}
    35  	})
    36  
    37  	t.Run("with valid status", func(t *testing.T) {
    38  		tests := []struct {
    39  			in       string
    40  			expected Status
    41  		}{
    42  			{"READONLY", StatusReadOnly},
    43  			{"READY", StatusReady},
    44  			{"INDEXING", StatusIndexing},
    45  		}
    46  
    47  		for _, test := range tests {
    48  			status, err := ValidateStatus(test.in)
    49  			require.Nil(t, err)
    50  			require.Equal(t, test.expected, status)
    51  		}
    52  	})
    53  }