mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
sdk: Fix fmt + add FieldType test (#19493)
* sdk: Fix fmt + add FieldType test * Add test comment
This commit is contained in:
@@ -2,6 +2,7 @@ package framework
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -811,3 +812,23 @@ func TestInitializeBackend(t *testing.T) {
|
||||
t.Fatal("backend should be open")
|
||||
}
|
||||
}
|
||||
|
||||
// TestFieldTypeMethods tries to ensure our switch-case statements for the
|
||||
// FieldType "enum" are complete.
|
||||
func TestFieldTypeMethods(t *testing.T) {
|
||||
unknownFormat := convertType(TypeInvalid).format
|
||||
|
||||
for i := TypeInvalid + 1; i < typeInvalidMax; i++ {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
if i.String() == TypeInvalid.String() {
|
||||
t.Errorf("unknown type string for %d", i)
|
||||
}
|
||||
|
||||
if convertType(i).format == unknownFormat {
|
||||
t.Errorf("unknown schema for %d", i)
|
||||
}
|
||||
|
||||
_ = i.Zero()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ const (
|
||||
// formatted as a string or a number. The resulting time.Time
|
||||
// is converted to UTC.
|
||||
TypeTime
|
||||
|
||||
// DO NOT USE. Any new values must be inserted before this value.
|
||||
// Used to write tests that ensure type methods handle all possible values.
|
||||
typeInvalidMax
|
||||
)
|
||||
|
||||
func (t FieldType) String() string {
|
||||
@@ -75,6 +79,8 @@ func (t FieldType) String() string {
|
||||
return "name string"
|
||||
case TypeInt:
|
||||
return "int"
|
||||
case TypeInt64:
|
||||
return "int64"
|
||||
case TypeBool:
|
||||
return "bool"
|
||||
case TypeMap:
|
||||
|
||||
Reference in New Issue
Block a user