Skip to content

Commit

Permalink
Fix Docker image tag and file path in Makefile and Dockerfile
Browse files Browse the repository at this point in the history
The Docker image tag and file path in the Makefile and Dockerfile have been fixed to use the correct repository name "Mainflux" instead of "sammyoina". This ensures that the Docker images are tagged and pushed to the correct repository. Additionally, the file path in the Dockerfile has been updated to correctly move the built executable to the desired location.

Signed-off-by: SammyOina <sammyoina@gmail.com>
  • Loading branch information
SammyOina committed Sep 28, 2023
1 parent 397d40e commit e667a83
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define make_docker
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg TIME=$(TIME) \
--tag=sammyoina/$(svc) \
--tag=Mainflux/$(svc) \
-f docker/Dockerfile .
endef

Expand Down Expand Up @@ -82,7 +82,7 @@ dockers_dev: $(DOCKERS_DEV)

define docker_push
for svc in $(SERVICES); do \
docker push sammyoina/$$svc:$(1); \
docker push mainflux/$$svc:$(1); \
done
endef

Expand Down
5 changes: 2 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ WORKDIR /go/src/github.com/mainflux/agent
COPY . .
RUN apk update \
&& apk add make\
&& make $SVC
RUN ls build
RUN mv build/mainflux-$SVC /exe
&& make $SVC \
&& mv build/mainflux-$SVC /exe

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
Expand Down
27 changes: 0 additions & 27 deletions pkg/edgex/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,31 @@ import (
const expectedResponse = "Response"

func TestPushOperation(t *testing.T) {
// Create a mock HTTP server
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check the HTTP request
if r.Method != http.MethodPost {
t.Errorf("Expected POST request, got %s", r.Method)
}

// Check the URL
expectedURL := "/operation"
if r.URL.String() != expectedURL {
t.Errorf("Expected URL %s, got %s", expectedURL, r.URL.String())
}

// Check the request body
expectedBody := `{"action":"start","services":["service1","service2"]}`
bodyBytes, _ := io.ReadAll(r.Body)
if string(bodyBytes) != expectedBody {
t.Errorf("Expected request body %s, got %s", expectedBody, string(bodyBytes))
}

// Respond with a dummy response
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte(expectedResponse)); err != nil {
t.Errorf("error writing response %v", err)
}
}))
defer server.Close()

// Create an edgexClient with the mock server URL
client := NewClient(server.URL+"/", logger.NewMock())

// Test PushOperation
response, err := client.PushOperation([]string{"start", "service1", "service2"})
if err != nil {
t.Errorf("Error calling PushOperation: %v", err)
Expand All @@ -55,32 +48,25 @@ func TestPushOperation(t *testing.T) {
}

func TestFetchConfig(t *testing.T) {

// Create a mock HTTP server
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check the HTTP request
if r.Method != http.MethodGet {
t.Errorf("Expected GET request, got %s", r.Method)
}

// Check the URL
expectedURL := "/config/start,service1,service2"
if r.URL.String() != expectedURL {
t.Errorf("Expected URL %s, got %s", expectedURL, r.URL.String())
}

// Respond with a dummy response
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte(expectedResponse)); err != nil {
t.Errorf("error writing response %v", err)
}
}))
defer server.Close()

// Create an edgexClient with the mock server URL
client := NewClient(server.URL+"/", logger.NewMock())

// Test FetchConfig
response, err := client.FetchConfig([]string{"start", "service1", "service2"})
if err != nil {
t.Errorf("Error calling FetchConfig: %v", err)
Expand All @@ -92,32 +78,25 @@ func TestFetchConfig(t *testing.T) {
}

func TestFetchMetrics(t *testing.T) {

// Create a mock HTTP server
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check the HTTP request
if r.Method != http.MethodGet {
t.Errorf("Expected GET request, got %s", r.Method)
}

// Check the URL
expectedURL := "/metrics/start,service1,service2"
if r.URL.String() != expectedURL {
t.Errorf("Expected URL %s, got %s", expectedURL, r.URL.String())
}

// Respond with a dummy response
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte(expectedResponse)); err != nil {
t.Errorf("error writing response %v", err)
}
}))
defer server.Close()

// Create an edgexClient with the mock server URL
client := NewClient(server.URL+"/", logger.NewMock())

// Test FetchMetrics
response, err := client.FetchMetrics([]string{"start", "service1", "service2"})
if err != nil {
t.Errorf("Error calling FetchMetrics: %v", err)
Expand All @@ -129,31 +108,25 @@ func TestFetchMetrics(t *testing.T) {
}

func TestPing(t *testing.T) {
// Create a mock HTTP server
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check the HTTP request
if r.Method != http.MethodGet {
t.Errorf("Expected GET request, got %s", r.Method)
}

// Check the URL
expectedURL := "/ping"
if r.URL.String() != expectedURL {
t.Errorf("Expected URL %s, got %s", expectedURL, r.URL.String())
}

// Respond with a dummy response
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte(expectedResponse)); err != nil {
t.Errorf("error writing response %v", err)
}
}))
defer server.Close()

// Create an edgexClient with the mock server URL
client := NewClient(server.URL+"/", logger.NewMock())

// Test Ping
response, err := client.Ping()
if err != nil {
t.Errorf("Error calling Ping: %v", err)
Expand Down

0 comments on commit e667a83

Please sign in to comment.