mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-29 13:49:28 +08:00

* Refactor Mainflux go SDK Add structures instead of string parameters. Add offset and limit parameters to things and channels methods. Add better configuration support. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add new public errors with better error handling Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update SDK to use uint instread of string id Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update cli to use new SDK API Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Remove TLS termination from nginx configuration Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update SDK documentation and structures Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Refactor things service Decouple HTTP layer from business logic. Remove ID number validation check. Remove models from HTTP requests and responses. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Reformat tests for things service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Increase test coverage for things service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
57 lines
1000 B
Go
57 lines
1000 B
Go
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package redis_test
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/go-redis/redis"
|
|
dockertest "gopkg.in/ory-am/dockertest.v3"
|
|
)
|
|
|
|
const (
|
|
wrongID = 0
|
|
wrongValue = "wrong-value"
|
|
)
|
|
|
|
var cacheClient *redis.Client
|
|
|
|
func TestMain(m *testing.M) {
|
|
pool, err := dockertest.NewPool("")
|
|
if err != nil {
|
|
log.Fatalf("Could not connect to docker: %s", err)
|
|
}
|
|
|
|
container, err := pool.Run("redis", "4.0.9-alpine", nil)
|
|
if err != nil {
|
|
log.Fatalf("Could not start container: %s", err)
|
|
}
|
|
|
|
// When you're done, kill and remove the container
|
|
defer pool.Purge(container)
|
|
|
|
if err := pool.Retry(func() error {
|
|
cacheClient = redis.NewClient(&redis.Options{
|
|
Addr: fmt.Sprintf("localhost:%s", container.GetPort("6379/tcp")),
|
|
Password: "",
|
|
DB: 0,
|
|
})
|
|
|
|
return cacheClient.Ping().Err()
|
|
}); err != nil {
|
|
log.Fatalf("Could not connect to docker: %s", err)
|
|
}
|
|
|
|
code := m.Run()
|
|
|
|
os.Exit(code)
|
|
}
|