Skip to content

Commit

Permalink
added integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuedding committed Mar 18, 2024
1 parent a0b8234 commit 1a15cbd
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3"
services:
iot-agent-sdk-test:
environment:
- APP_ENV=test
- TEST_HOST=iot-agent1
- LOG_LEVEL=DEBUG
- TZ:"Europe/Berlin"
build:
dockerfile: test.Dockerfile
context: ./
ports:
- 8080:8080
depends_on:
- iot-agent
- mongodb
- orion
iot-agent:
image: fiware/iotagent-ul:latest
hostname: iot-agent
depends_on:
- mongodb
expose:
- "4061"
- "7896"
ports:
- "4061:4061"
- "7896:7896"
environment:
- "IOTA_CB_HOST=orion"
- "IOTA_CB_PORT=1026"
- "IOTA_NORTH_PORT=4061"
- "IOTA_REGISTRY_TYPE=mongodb"
- "IOTA_MONGO_HOST=mongodb"
- "IOTA_MONGO_PORT=27017"
- "IOTA_MONGO_DB=iotagent-ul"
- "IOTA_HTTP_PORT=7896"
- "IOTA_PROVIDER_URL=http://iot-agent:4061"
mongodb:
image: mongo:4.2
hostname: mongodb
ports:
- "27017:27017"
command: --bind_ip_all
orion:
image: fiware/orion
hostname: orion
depends_on:
- mongodb
expose:
- "1026"
ports:
- "1026:1026"
command: -dbhost mongodb


8 changes: 7 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package iotagentsdk_test

import (
"os"
"testing"

i "github.com/fbuedding/fiware-iot-agent-sdk"
Expand All @@ -25,7 +26,12 @@ const (
)

func TestMain(m *testing.M) {
iota = i.IoTA{Host: "localhost", Port: 4061}
host := "localhost"
if os.Getenv("TEST_HOST") != "" {
host = os.Getenv("TEST_HOST")
}
log.Info().Msgf("Starting test with iot-agent host: %s", host)
iota = i.IoTA{Host: host, Port: 4061}
fs = i.FiwareService{Service: service, ServicePath: servicePath}
d = i.Device{Id: deviceId, EntityName: entityName}
sg = i.ConfigGroup{
Expand Down
17 changes: 17 additions & 0 deletions test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Go image as a base image
FROM golang:latest

# Set the working directory inside the container
WORKDIR /app

# Copy the go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies
RUN go mod download

# Copy the source from the current directory to the working directory inside the container
COPY . .

# Command to run the tests
CMD ["go", "test", "-v", "./..."]

0 comments on commit 1a15cbd

Please sign in to comment.