Skip to content

Commit

Permalink
Merge pull request #1378 from gofr-dev/release/v1.30.0
Browse files Browse the repository at this point in the history
Release/v1.30.0
  • Loading branch information
aryanmehrotra authored Jan 10, 2025
2 parents 5bc6ec2 + f982983 commit a197221
Show file tree
Hide file tree
Showing 45 changed files with 1,484 additions and 529 deletions.
10 changes: 9 additions & 1 deletion examples/grpc-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"context"
"fmt"
"strconv"
"testing"
"time"

Expand All @@ -11,10 +13,16 @@ import (
"google.golang.org/grpc/credentials/insecure"

grpcExample "gofr.dev/examples/grpc-server/grpc"
"gofr.dev/pkg/gofr/testutil"
)

func TestGRPCServer(t *testing.T) {
const host = "localhost:10000"
gRPCPort := testutil.GetFreePort(t)
t.Setenv("GRPC_PORT", strconv.Itoa(gRPCPort))
host := fmt.Sprint("localhost:", gRPCPort)

port := testutil.GetFreePort(t)
t.Setenv("METRICS_PORT", strconv.Itoa(port))

go main()
time.Sleep(100 * time.Millisecond)
Expand Down
26 changes: 23 additions & 3 deletions examples/http-server-using-redis/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package main
import (
"bytes"
"context"
"fmt"
"net/http"
"strconv"
"testing"
"time"

Expand All @@ -21,7 +23,13 @@ import (
)

func TestHTTPServerUsingRedis(t *testing.T) {
const host = "http://localhost:8000"
httpPort := testutil.GetFreePort(t)
t.Setenv("HTTP_PORT", strconv.Itoa(httpPort))
host := fmt.Sprint("http://localhost:", httpPort)

port := testutil.GetFreePort(t)
t.Setenv("METRICS_PORT", strconv.Itoa(port))

go main()
time.Sleep(100 * time.Millisecond) // Giving some time to start the server

Expand Down Expand Up @@ -55,6 +63,12 @@ func TestHTTPServerUsingRedis(t *testing.T) {
}

func TestRedisSetHandler(t *testing.T) {
metricsPort := testutil.GetFreePort(t)
httpPort := testutil.GetFreePort(t)

t.Setenv("METRICS_PORT", strconv.Itoa(metricsPort))
t.Setenv("HTTP_PORT", strconv.Itoa(httpPort))

a := gofr.New()
logger := logging.NewLogger(logging.DEBUG)
redisClient, mock := redismock.NewClientMock()
Expand All @@ -64,7 +78,7 @@ func TestRedisSetHandler(t *testing.T) {

mock.ExpectSet("key", "value", 5*time.Minute).SetErr(testutil.CustomError{ErrorMessage: "redis get error"})

req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://localhost:5000/handle", bytes.NewBuffer([]byte(`{"key":"value"}`)))
req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, fmt.Sprintf("http://localhost:%d/handle", httpPort), bytes.NewBuffer([]byte(`{"key":"value"}`)))
req.Header.Set("content-type", "application/json")
gofrReq := gofrHTTP.NewRequest(req)

Expand All @@ -78,6 +92,12 @@ func TestRedisSetHandler(t *testing.T) {
}

func TestRedisPipelineHandler(t *testing.T) {
metricsPort := testutil.GetFreePort(t)
httpPort := testutil.GetFreePort(t)

t.Setenv("METRICS_PORT", strconv.Itoa(metricsPort))
t.Setenv("HTTP_PORT", strconv.Itoa(httpPort))

a := gofr.New()
logger := logging.NewLogger(logging.DEBUG)
redisClient, mock := redismock.NewClientMock()
Expand All @@ -88,7 +108,7 @@ func TestRedisPipelineHandler(t *testing.T) {
mock.ExpectSet("testKey1", "testValue1", time.Minute*5).SetErr(testutil.CustomError{ErrorMessage: "redis get error"})
mock.ClearExpect()

req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://localhost:5000/handle", bytes.NewBuffer([]byte(`{"key":"value"}`)))
req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, fmt.Sprint("http://localhost:", httpPort, "/handle"), bytes.NewBuffer([]byte(`{"key":"value"}`)))
req.Header.Set("content-type", "application/json")

gofrReq := gofrHTTP.NewRequest(req)
Expand Down
18 changes: 16 additions & 2 deletions examples/http-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"io"
"net/http"
"strconv"
"testing"
"time"

Expand All @@ -20,9 +21,12 @@ import (
"gofr.dev/pkg/gofr/testutil"
)

const host = "http://localhost:9000"

func TestIntegration_SimpleAPIServer(t *testing.T) {
host := "http://localhost:9000"

port := testutil.GetFreePort(t)
t.Setenv("METRICS_PORT", strconv.Itoa(port))

go main()
time.Sleep(100 * time.Millisecond) // Giving some time to start the server

Expand Down Expand Up @@ -66,6 +70,8 @@ func TestIntegration_SimpleAPIServer(t *testing.T) {
}

func TestIntegration_SimpleAPIServer_Errors(t *testing.T) {
host := "http://localhost:9000"

tests := []struct {
desc string
path string
Expand Down Expand Up @@ -120,6 +126,8 @@ func TestIntegration_SimpleAPIServer_Errors(t *testing.T) {
}

func TestIntegration_SimpleAPIServer_Health(t *testing.T) {
host := "http://localhost:9000"

tests := []struct {
desc string
path string
Expand All @@ -143,6 +151,12 @@ func TestIntegration_SimpleAPIServer_Health(t *testing.T) {
}

func TestRedisHandler(t *testing.T) {
metricsPort := testutil.GetFreePort(t)
httpPort := testutil.GetFreePort(t)

t.Setenv("METRICS_PORT", strconv.Itoa(metricsPort))
t.Setenv("HTTP_PORT", strconv.Itoa(httpPort))

a := gofr.New()
logger := logging.NewLogger(logging.DEBUG)
redisClient, mock := redismock.NewClientMock()
Expand Down
96 changes: 49 additions & 47 deletions examples/using-add-filestore/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ go 1.23.2
require (
github.com/stretchr/testify v1.10.0
go.uber.org/mock v0.5.0
gofr.dev v1.28.0
gofr.dev/pkg/gofr/datasource/file/ftp v0.1.0
gofr.dev v1.29.0
gofr.dev/pkg/gofr/datasource/file/ftp v0.2.0
)

require (
cloud.google.com/go v0.116.0 // indirect
cloud.google.com/go/auth v0.10.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
cloud.google.com/go/iam v1.2.2 // indirect
cloud.google.com/go/pubsub v1.45.1 // indirect
cloud.google.com/go v0.118.0 // indirect
cloud.google.com/go/auth v0.14.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.6 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.3.1 // indirect
cloud.google.com/go/pubsub v1.45.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/DATA-DOG/go-sqlmock v1.5.2 // indirect
github.com/XSAM/otelsql v0.34.0 // indirect
github.com/XSAM/otelsql v0.36.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand All @@ -32,72 +32,74 @@ require (
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.0 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/jlaffaye/ftp v0.2.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/common v0.61.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.0 // indirect
github.com/redis/go-redis/extra/redisotel/v9 v9.7.0 // indirect
github.com/redis/go-redis/v9 v9.7.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/segmentio/kafka-go v0.4.47 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.52.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.58.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
go.opentelemetry.io/otel v1.33.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.55.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.33.0 // indirect
go.opentelemetry.io/otel/metric v1.33.0 // indirect
go.opentelemetry.io/otel/sdk v1.33.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.33.0 // indirect
go.opentelemetry.io/otel/trace v1.33.0 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/api v0.209.0 // indirect
google.golang.org/genproto v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/api v0.215.0 // indirect
google.golang.org/genproto v0.0.0-20250106144421-5f5ef82da422 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422 // indirect
google.golang.org/grpc v1.69.2 // indirect
google.golang.org/protobuf v1.36.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.55.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.34.1 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/gc/v3 v3.0.0-20250105121824-520be1a3aee6 // indirect
modernc.org/libc v1.61.7 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.8.1 // indirect
modernc.org/sqlite v1.34.4 // indirect
modernc.org/strutil v1.2.1 // indirect
modernc.org/token v1.1.0 // indirect
)
Loading

0 comments on commit a197221

Please sign in to comment.