a9d81a1094
remove parallel to stabilize ci/cd
75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
package queryapi_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
queryapi "queryorchestration/api/queryAPI"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetClientStatus(t *testing.T) {
|
|
cfg := &ControllerConfig{}
|
|
test.CreateDB(t, cfg)
|
|
initializeTestConfig(t, cfg)
|
|
|
|
svc := createControllerServices(cfg)
|
|
cons := queryapi.NewControllers(svc, cfg)
|
|
|
|
ctx, rec := createContext(t)
|
|
|
|
clientId := "clientid"
|
|
|
|
err := cfg.GetDBQueries().CreateClient(t.Context(), &repository.CreateClientParams{
|
|
Clientid: clientId,
|
|
Name: "client_name",
|
|
})
|
|
require.NoError(t, err)
|
|
err = cfg.GetDBQueries().AddClientCanSync(t.Context(), &repository.AddClientCanSyncParams{
|
|
Clientid: clientId,
|
|
Cansync: true,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
err = cons.GetStatusByClientId(ctx, clientId)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, http.StatusOK, rec.Code)
|
|
assertBody(t, rec, queryapi.ClientStatusBody{
|
|
Status: queryapi.INSYNC,
|
|
})
|
|
}
|
|
|
|
func BenchmarkGetClientStatus(b *testing.B) {
|
|
cfg := &ControllerConfig{}
|
|
test.CreateDB(b, cfg)
|
|
initializeTestConfig(b, cfg)
|
|
|
|
svc := createControllerServices(cfg)
|
|
cons := queryapi.NewControllers(svc, cfg)
|
|
|
|
ctx, _ := createContext(b)
|
|
|
|
clientId := "clientid"
|
|
|
|
err := cfg.GetDBQueries().CreateClient(b.Context(), &repository.CreateClientParams{
|
|
Clientid: clientId,
|
|
Name: "client_name",
|
|
})
|
|
require.NoError(b, err)
|
|
err = cfg.GetDBQueries().AddClientCanSync(b.Context(), &repository.AddClientCanSyncParams{
|
|
Clientid: clientId,
|
|
Cansync: true,
|
|
})
|
|
require.NoError(b, err)
|
|
|
|
b.ResetTimer()
|
|
|
|
for b.Loop() {
|
|
_ = cons.GetStatusByClientId(ctx, clientId)
|
|
}
|
|
}
|