-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: add multiple database configuration
This will give us the ability to add additional database backends if the need arises. Signed-off-by: Hank Donnay <hdonnay@redhat.com>
- Loading branch information
Showing
6 changed files
with
184 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestDatabaseUnmarshal(t *testing.T) { | ||
want := Database{ | ||
Name: "postgresql", | ||
PostgreSQL: &DatabasePostgreSQL{ | ||
DSN: "host=test", | ||
}, | ||
} | ||
input := []string{ | ||
`{"name":"postgresql","postgresql":{"dsn":"host=test"}}`, | ||
} | ||
|
||
for _, tc := range input { | ||
t.Logf("testing: %#q", tc) | ||
var got Database | ||
if err := json.Unmarshal([]byte(tc), &got); err != nil { | ||
t.Error(err) | ||
continue | ||
} | ||
ws, err := got.lint() | ||
if err != nil { | ||
t.Error(err) | ||
continue | ||
} | ||
for _, w := range ws { | ||
t.Logf("got lint: %v", &w) | ||
} | ||
if !cmp.Equal(&got, &want) { | ||
t.Error(cmp.Diff(&got, &want)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters