Skip to content

Commit 8e144b7

Browse files
authored
Merge branch 'development' into patch-3
2 parents 04047f0 + 7723b31 commit 8e144b7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

examples/using-custom-metrics/main_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ func TestIntegration(t *testing.T) {
5454

5555
assert.Equal(t, http.StatusOK, resp.StatusCode, "TEST[%d], Failed.\n%s")
5656

57-
assert.Contains(t, strBody, `product_stock{otel_scope_name="using-metrics",otel_scope_version="v0.1.0"} 50`)
58-
assert.Contains(t, strBody, `total_credit_day_sale{otel_scope_name="using-metrics",otel_scope_version="v0.1.0",sale_type="credit"} 1000`)
59-
assert.Contains(t, strBody, `total_credit_day_sale{otel_scope_name="using-metrics",otel_scope_version="v0.1.0",sale_type="credit_return"} -1000`)
60-
assert.Contains(t, strBody, `transaction_success_total{otel_scope_name="using-metrics",otel_scope_version="v0.1.0"} 1`)
57+
assert.Contains(t, strBody, `product_stock{otel_scope_name="using-metrics",otel_scope_schema_url="",otel_scope_version="v0.1.0"} 50`)
58+
assert.Contains(t, strBody, `total_credit_day_sale{otel_scope_name="using-metrics",otel_scope_schema_url="",otel_scope_version="v0.1.0",sale_type="credit"} 1000`)
59+
assert.Contains(t, strBody, `total_credit_day_sale{otel_scope_name="using-metrics",otel_scope_schema_url="",otel_scope_version="v0.1.0",sale_type="credit_return"} -1000`)
60+
assert.Contains(t, strBody, `transaction_success{otel_scope_name="using-metrics",otel_scope_schema_url="",otel_scope_version="v0.1.0"} 1`)
6161
assert.Contains(t, strBody, "transaction_time")
6262
}

examples/using-http-service/main_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/stretchr/testify/assert"
1515
"github.com/stretchr/testify/require"
16+
"go.uber.org/mock/gomock"
1617

1718
"gofr.dev/pkg/gofr"
1819
"gofr.dev/pkg/gofr/container"
@@ -82,12 +83,15 @@ func TestHTTPHandlerURLError(t *testing.T) {
8283
fmt.Sprint("http://localhost:", port, "/handle"), bytes.NewBuffer([]byte(`{"key":"value"}`)))
8384
gofrReq := gofrHTTP.NewRequest(req)
8485

85-
mockContainer, _ := container.NewMockContainer(t)
86+
mockContainer, mocks := container.NewMockContainer(t)
8687

8788
ctx := &gofr.Context{Context: context.Background(), Request: gofrReq, Container: mockContainer}
8889

8990
ctx.Container.Services = map[string]service.HTTP{"cat-facts": service.NewHTTPService("http://invalid", ctx.Logger, mockContainer.Metrics())}
9091

92+
mocks.Metrics.EXPECT().RecordHistogram(gomock.Any(), "app_http_service_response", gomock.Any(), gomock.Any(),
93+
"http://invalid", "method", "GET", "status", gomock.Any())
94+
9195
resp, err := Handler(ctx)
9296

9397
assert.Nil(t, resp)

0 commit comments

Comments
 (0)