File: counter_test.go

package info (click to toggle)
golang-github-openfga-go-sdk 0.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 1,960 kB
  • sloc: makefile: 13
file content (89 lines) | stat: -rw-r--r-- 2,634 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package telemetry

import (
	"testing"
)

func TestCounterCreation(t *testing.T) {
	counterName := "test-counter"
	counterDescription := "This is a test counter."

	counter := &Counter{
		Name:        counterName,
		Description: counterDescription,
	}

	if counter.GetName() != counterName {
		t.Errorf("Expected Counter Name to be '%s', but got '%s'", counterName, counter.GetName())
	}

	if counter.GetDescription() != counterDescription {
		t.Errorf("Expected Counter Description to be '%s', but got '%s'", counterDescription, counter.GetDescription())
	}
}

func TestEmptyCounterCreation(t *testing.T) {
	counter := &Counter{}

	if counter.GetName() != "" {
		t.Errorf("Expected Counter Name to be empty, but got '%s'", counter.GetName())
	}

	if counter.GetDescription() != "" {
		t.Errorf("Expected Counter Description to be empty, but got '%s'", counter.GetDescription())
	}
}

func TestCounterWithWhitespaceName(t *testing.T) {
	counterName := " "
	counterDescription := "Counter with whitespace name."

	counter := &Counter{
		Name:        counterName,
		Description: counterDescription,
	}

	if counter.GetName() != counterName {
		t.Errorf("Expected Counter Name to be '%s', but got '%s'", counterName, counter.GetName())
	}

	if counter.GetDescription() != counterDescription {
		t.Errorf("Expected Counter Description to be '%s', but got '%s'", counterDescription, counter.GetDescription())
	}
}

func TestCounterWithSpecialCharacters(t *testing.T) {
	counterName := "!@#$%^&*()_+{}|:\"<>?"
	counterDescription := "Description with special characters: !@#$%^&*()_+{}|:\"<>?"

	counter := &Counter{
		Name:        counterName,
		Description: counterDescription,
	}

	if counter.GetName() != counterName {
		t.Errorf("Expected Counter Name to be '%s', but got '%s'", counterName, counter.GetName())
	}

	if counter.GetDescription() != counterDescription {
		t.Errorf("Expected Counter Description to be '%s', but got '%s'", counterDescription, counter.GetDescription())
	}
}

func TestCounterWithLongNameAndDescription(t *testing.T) {
	counterName := "ThisIsAVeryLongCounterNameToTestEdgeCasesInTheTelemetryModule"
	counterDescription := "This is a very long description to test how the Counter struct handles long strings."

	counter := &Counter{
		Name:        counterName,
		Description: counterDescription,
	}

	if counter.GetName() != counterName {
		t.Errorf("Expected Counter Name to be '%s', but got '%s'", counterName, counter.GetName())
	}

	if counter.GetDescription() != counterDescription {
		t.Errorf("Expected Counter Description to be '%s', but got '%s'", counterDescription, counter.GetDescription())
	}
}