Skip to content

Commit c0045f7

Browse files
committed
test: added some edge case tests
1 parent 2091db7 commit c0045f7

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

internal/model/config/entry_config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import (
1111

1212
func TestEntryConfig(t *testing.T) {
1313
cfg := config.EntryConfig{
14+
Name: "test",
1415
TokenCreatedAt: time.Now(),
1516
TokenExpiresAt: time.Now(),
1617
}
1718

19+
require.EqualValues(t, "test", cfg.GetName())
1820
require.Contains(t, cfg.LogicalResponseData(true), "token")
1921
require.NotContains(t, cfg.LogicalResponseData(false), "token")
2022
}

internal/model/config/entry_config_update_form_field_data_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,44 @@ func TestEntryConfigUpdateFromFieldData(t *testing.T) {
7878
"base_url": "https://gitlab.com",
7979
},
8080
},
81+
{
82+
name: "auto_rotate_before specified (valid) should not warn and should set duration",
83+
expectedConfig: &config.EntryConfig{
84+
Token: "token",
85+
Type: gitlab2.TypeSelfManaged,
86+
AutoRotateToken: false,
87+
AutoRotateBefore: config.DefaultAutoRotateBeforeMinTTL,
88+
BaseURL: "https://gitlab.com",
89+
},
90+
warnings: nil,
91+
raw: map[string]interface{}{
92+
"token": "token",
93+
"type": gitlab2.TypeSelfManaged.String(),
94+
"base_url": "https://gitlab.com",
95+
"auto_rotate_before": int(config.DefaultAutoRotateBeforeMinTTL.Seconds()),
96+
},
97+
},
98+
{
99+
name: "auto_rotate_before specified (too small) should error",
100+
expectedConfig: &config.EntryConfig{
101+
Token: "token",
102+
Type: gitlab2.TypeSelfManaged,
103+
AutoRotateToken: false,
104+
AutoRotateBefore: 0,
105+
BaseURL: "https://gitlab.com",
106+
},
107+
warnings: nil,
108+
raw: map[string]interface{}{
109+
"token": "token",
110+
"type": gitlab2.TypeSelfManaged.String(),
111+
"base_url": "https://gitlab.com",
112+
"auto_rotate_before": int(config.DefaultAutoRotateBeforeMinTTL.Seconds()) - 1,
113+
},
114+
err: true,
115+
errMap: map[string]int{
116+
errs.ErrInvalidValue.Error(): 1,
117+
},
118+
},
81119
}
82120

83121
for _, test := range tests {

0 commit comments

Comments
 (0)