mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 08:50:46 +00:00
Rename 'MapDS' to 'JsonDS'; Added some docs
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Collections(t *testing.T) {
|
||||
presets := []testPreset{PresetMapStore, PresetBadgerStore}
|
||||
presets := []testPreset{PresetJsonStore, PresetBadgerStore}
|
||||
|
||||
setUp := func(ts *TestServer, client *azcosmos.Client) *azcosmos.DatabaseClient {
|
||||
ts.DataStore.CreateDatabase(datastore.Database{ID: testDatabaseName})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/pikami/cosmium/api/config"
|
||||
"github.com/pikami/cosmium/internal/datastore"
|
||||
badgerdatastore "github.com/pikami/cosmium/internal/datastore/badger_datastore"
|
||||
mapdatastore "github.com/pikami/cosmium/internal/datastore/map_datastore"
|
||||
jsondatastore "github.com/pikami/cosmium/internal/datastore/json_datastore"
|
||||
"github.com/pikami/cosmium/internal/logger"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func getDefaultTestServerConfig() *config.ServerConfig {
|
||||
AccountKey: config.DefaultAccountKey,
|
||||
ExplorerPath: "/tmp/nothing",
|
||||
ExplorerBaseUrlLocation: config.ExplorerBaseUrlLocation,
|
||||
DataStore: "map",
|
||||
DataStore: "json",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ func runTestServerCustomConfig(configuration *config.ServerConfig) *TestServer {
|
||||
var dataStore datastore.DataStore
|
||||
switch configuration.DataStore {
|
||||
case config.DataStoreBadger:
|
||||
dataStore = badgerdatastore.NewBadgerDataStore()
|
||||
dataStore = badgerdatastore.NewBadgerDataStore(badgerdatastore.BadgerDataStoreOptions{})
|
||||
default:
|
||||
dataStore = mapdatastore.NewMapDataStore(mapdatastore.MapDataStoreOptions{})
|
||||
dataStore = jsondatastore.NewJsonDataStore(jsondatastore.JsonDataStoreOptions{})
|
||||
}
|
||||
|
||||
api := api.NewApiServer(dataStore, configuration)
|
||||
@@ -71,7 +71,7 @@ type testFunc func(t *testing.T, ts *TestServer, cosmosClient *azcosmos.Client)
|
||||
type testPreset string
|
||||
|
||||
const (
|
||||
PresetMapStore testPreset = "MapDS"
|
||||
PresetJsonStore testPreset = "JsonDS"
|
||||
PresetBadgerStore testPreset = "BadgerDS"
|
||||
)
|
||||
|
||||
@@ -84,8 +84,8 @@ func runTestsWithPreset(t *testing.T, name string, testPreset testPreset, f test
|
||||
switch testPreset {
|
||||
case PresetBadgerStore:
|
||||
serverConfig.DataStore = config.DataStoreBadger
|
||||
case PresetMapStore:
|
||||
serverConfig.DataStore = config.DataStoreMap
|
||||
case PresetJsonStore:
|
||||
serverConfig.DataStore = config.DataStoreJson
|
||||
}
|
||||
|
||||
ts := runTestServerCustomConfig(serverConfig)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Databases(t *testing.T) {
|
||||
presets := []testPreset{PresetMapStore, PresetBadgerStore}
|
||||
presets := []testPreset{PresetJsonStore, PresetBadgerStore}
|
||||
|
||||
runTestsWithPresets(t, "Database Create", presets, func(t *testing.T, ts *TestServer, client *azcosmos.Client) {
|
||||
t.Run("Should create database", func(t *testing.T) {
|
||||
|
||||
@@ -81,7 +81,7 @@ func documents_InitializeDb(t *testing.T, ts *TestServer) *azcosmos.ContainerCli
|
||||
}
|
||||
|
||||
func Test_Documents(t *testing.T) {
|
||||
presets := []testPreset{PresetMapStore, PresetBadgerStore}
|
||||
presets := []testPreset{PresetJsonStore, PresetBadgerStore}
|
||||
|
||||
runTestsWithPresets(t, "Test_Documents", presets, func(t *testing.T, ts *TestServer, client *azcosmos.Client) {
|
||||
collectionClient := documents_InitializeDb(t, ts)
|
||||
|
||||
Reference in New Issue
Block a user