MCPcopy Index your code
hub / github.com/dreamsofcode-io/zenstats / TestConfigValidation

Function TestConfigValidation

internal/config/database_test.go:142–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestConfigValidation(t *testing.T) {
143 valid := config.Database{
144 Username: "pguser",
145 Password: "pgpassword",
146 Host: "pghost",
147 Port: 5432,
148 DBName: "pgdatabase",
149 SSLMode: "disable",
150 }
151
152 t.Run("Test valid", func(t *testing.T) {
153 valid := valid
154 assert.NoError(t, valid.Validate())
155 })
156
157 t.Run("Test invalid username", func(t *testing.T) {
158 valid := valid
159 valid.Username = ""
160 assert.EqualError(t, valid.Validate(), "invalid username")
161 })
162
163 t.Run("Test invalid password", func(t *testing.T) {
164 valid := valid
165 valid.Password = ""
166 assert.EqualError(t, valid.Validate(), "invalid password")
167 })
168
169 t.Run("Test invalid host", func(t *testing.T) {
170 valid := valid
171 valid.Host = ""
172 assert.EqualError(t, valid.Validate(), "invalid host")
173 })
174
175 t.Run("Test invalid port", func(t *testing.T) {
176 valid := valid
177 valid.Port = 0
178 assert.EqualError(t, valid.Validate(), "invalid port")
179 })
180
181 t.Run("Test invalid name", func(t *testing.T) {
182 valid := valid
183 valid.DBName = ""
184 assert.EqualError(t, valid.Validate(), "invalid database name")
185 })
186}

Callers

nothing calls this directly

Calls 1

ValidateMethod · 0.95

Tested by

no test coverage detected