67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
//go:build conftests
|
|
// +build conftests
|
|
|
|
/*
|
|
Copyright 2023 The Dapr Authors
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package conformance
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/dapr/components-contrib/lock"
|
|
l_redis "github.com/dapr/components-contrib/lock/redis"
|
|
conf_lock "github.com/dapr/components-contrib/tests/conformance/lock"
|
|
)
|
|
|
|
func TestLockConformance(t *testing.T) {
|
|
const configPath = "../config/lock/"
|
|
tc, err := NewTestConfiguration(filepath.Join(configPath, "tests.yml"))
|
|
require.NoError(t, err)
|
|
require.NotNil(t, tc)
|
|
|
|
tc.TestFn = func(comp *TestComponent) func(t *testing.T) {
|
|
return func(t *testing.T) {
|
|
ParseConfigurationMap(t, comp.Config)
|
|
|
|
componentConfigPath := convertComponentNameToPath(comp.Component, comp.Profile)
|
|
props, err := loadComponentsAndProperties(t, filepath.Join(configPath, componentConfigPath))
|
|
require.NoErrorf(t, err, "error running conformance test for component %s", comp.Component)
|
|
|
|
component := loadLockStore(comp.Component)
|
|
require.NotNil(t, component, "error running conformance test for component %s", comp.Component)
|
|
|
|
lockConfig, err := conf_lock.NewTestConfig(comp.Component, comp.Operations, comp.Config)
|
|
require.NoErrorf(t, err, "error running conformance test for component %s", comp.Component)
|
|
|
|
conf_lock.ConformanceTests(t, props, component, lockConfig)
|
|
}
|
|
}
|
|
|
|
tc.Run(t)
|
|
}
|
|
|
|
func loadLockStore(name string) lock.Store {
|
|
switch name {
|
|
case "redis.v6":
|
|
return l_redis.NewStandaloneRedisLock(testLogger)
|
|
case "redis.v7":
|
|
return l_redis.NewStandaloneRedisLock(testLogger)
|
|
default:
|
|
return nil
|
|
}
|
|
}
|