File: ulid_test.go

package info (click to toggle)
golang-github-openfga-go-sdk 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,012 kB
  • sloc: makefile: 13
file content (61 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * Go SDK for OpenFGA
 *
 * API version: 1.x
 * Website: https://openfga.dev
 * Documentation: https://openfga.dev/docs
 * Support: https://openfga.dev/community
 * License: [Apache-2.0](https://github.com/openfga/go-sdk/blob/main/LICENSE)
 *
 * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
 */

package internalutils

import (
	"testing"
)

func TestIsWellFormedUlidString(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		isValid bool
	}{
		{
			name:    "valid_ulid",
			input:   "01GRC27AM72M4SGK4VBHF3DY0F",
			isValid: true,
		},
		{
			name:    "invalid_symbols",
			input:   "01GRC27AM72M4S$^4VBHF3DY0F",
			isValid: false,
		},
		{
			name:    "not_start_in_0-7",
			input:   "A1GRC27AM72M4SGK4VBHF3DY0F",
			isValid: false,
		},
		{
			name:    "too_long",
			input:   "01GRC27AM72M4SGK4VBHF3DY0FA",
			isValid: false,
		},
		{
			name:    "too_short",
			input:   "01GRC27AM72M4SGK4VBHF3DY0",
			isValid: false,
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			isValid := IsWellFormedUlidString(test.input)
			if isValid != test.isValid {
				t.Errorf("Expect %s to be valid %v actual %v", test.input, test.isValid, isValid)
			}
		})
	}

}