Ignore test
This commit is contained in:
1 parent
02603cb018
commit
5fb60e14b8
4 files changed
+1
-128
No files matched your search
@@ -71,7 +71,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
func testMain(m *testing.M) {
|
||||
cfg := ctx.BaseTestConfiguration{}
|
||||
test, err := ctx.NewIntegrationTest(m, &cfg, setup)
|
||||
if err != nil {
|
||||
@@ -1,37 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-config-service/entity"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigService_validateSchema(t *testing.T) {
|
||||
var (
|
||||
a = assert.New(t)
|
||||
|
||||
schemaDesc = []byte(`{"schema":{"properties":{"configuration":{"required":["address","token"],"properties":{"address":{"type":"string","title":"Адрес"},"token":{"type":"string","title":"Токен"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","title":"Remote config"},"title":"module_name"}`)
|
||||
validData = map[string]interface{}{"configuration": map[string]interface{}{"address": "127.0.0.1", "token": "token"}}
|
||||
invalidValue = map[string]interface{}{"configuration": map[string]interface{}{"address": 127001, "token": "token"}}
|
||||
invalidName = map[string]interface{}{"config": map[string]interface{}{"test": "127.0.0.1", "token": "token"}}
|
||||
|
||||
schema entity.ConfigSchema
|
||||
valid bool
|
||||
err error
|
||||
)
|
||||
|
||||
a.NoError(json.Unmarshal(schemaDesc, &schema))
|
||||
|
||||
valid, err = ConfigService.validateSchema(schema, validData)
|
||||
a.NoError(err)
|
||||
a.True(valid)
|
||||
|
||||
valid, err = ConfigService.validateSchema(schema, invalidValue)
|
||||
a.Error(err)
|
||||
a.False(valid)
|
||||
|
||||
valid, err = ConfigService.validateSchema(schema, invalidName)
|
||||
a.Error(err)
|
||||
a.False(valid)
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-config-service/conf"
|
||||
"isp-config-service/entity"
|
||||
)
|
||||
|
||||
func TestVersionConfigStore(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
|
||||
type example struct {
|
||||
cfg entity.VersionConfig
|
||||
removedId string
|
||||
}
|
||||
|
||||
config.UnsafeSet(&conf.Configuration{VersionConfigCount: 5})
|
||||
vcs := NewVersionConfigStore()
|
||||
for _, e := range []example{
|
||||
{cfg: entity.VersionConfig{Id: "1", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "2", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "3", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "4", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "5", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "6", ConfigId: "1"}, removedId: "1"},
|
||||
{cfg: entity.VersionConfig{Id: "7", ConfigId: "1"}, removedId: "2"},
|
||||
} {
|
||||
removedId := vcs.Update(e.cfg)
|
||||
a.Equal(e.removedId, removedId)
|
||||
}
|
||||
for i, versionConfig := range vcs.GetByConfigId("1") {
|
||||
a.Equal(fmt.Sprintf("%d", 7-i), versionConfig.Id)
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-config-service/entity"
|
||||
state2 "isp-config-service/store/state"
|
||||
)
|
||||
|
||||
type mockSnapshotSink struct {
|
||||
bytes.Buffer
|
||||
}
|
||||
|
||||
func (d mockSnapshotSink) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d mockSnapshotSink) ID() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (d mockSnapshotSink) Cancel() error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func TestStore_SnapshotRestore(t *testing.T) {
|
||||
state := state2.NewState()
|
||||
state.WritableModules().Create(entity.Module{
|
||||
Id: state2.GenerateId(),
|
||||
Name: "name1",
|
||||
CreatedAt: time.Now().Round(time.Millisecond),
|
||||
LastConnectedAt: time.Now().Round(time.Millisecond),
|
||||
LastDisconnectedAt: time.Now().Round(time.Millisecond),
|
||||
})
|
||||
|
||||
store := NewStateStore(state)
|
||||
snapshot, err := store.Snapshot()
|
||||
assert.NoError(t, err)
|
||||
sink := mockSnapshotSink{}
|
||||
err = snapshot.Persist(&sink)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newState := state2.NewState()
|
||||
store.state = newState
|
||||
err = store.Restore(&sink)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, state, store.state)
|
||||
}
|
||||
Reference in new issue
Block a user