예제 #1
0
func CreateDbInfo(dbConfig fileReaders.JsonObject) string {
	dbinfo := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable SEARCH_PATH=%s ",
		DB_USER, DB_PASSWORD, DB_NAME, DB_SCHEMA)

	if dbConfig.IsInOrder() {
		dbinfo = fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable SEARCH_PATH=%s ",
			dbConfig.DB_USER, dbConfig.DB_PASSWORD, dbConfig.DB_NAME, dbConfig.DB_SCHEMA)
	}

	return dbinfo
}
예제 #2
0
func TestCreateDbInfo(t *testing.T) {
	jsonObject := fileReaders.JsonObject{}
	jsonObject.DB_NAME = "sql"
	jsonObject.DB_PASSWORD = "******"
	jsonObject.DB_SCHEMA = "students"
	jsonObject.DB_USER = "******"

	expected := "user=sqlUser password=something dbname=sql sslmode=disable SEARCH_PATH=students "

	assert.Equal(t, expected, CreateDbInfo(jsonObject))

}