Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This decouples the test from the actual system and allows us to change the imple

All tests, be it unit tests, service level tests or end to end integration tests, should follow the same methodology, only the SUT changes in all cases.

![test](https://github.com/Swiggy/grill/blob/media/testing.png?raw=true)
![test](https://github.com/singh-jatin28/grill/blob/media/testing.png?raw=true)

## Motivation
With rapid adoption of microservices architecture at Swiggy, we realized the limitation of unit tests. Especially for I/O bound microservice which
Expand Down Expand Up @@ -71,7 +71,7 @@ It uses testcontainers-go underneath for dockers.
| ES | CreateIndex, PutItem | AssertItemsCount | DeleteIndices, DeleteItem |

## Getting Started
Check the [Wiki page](https://github.com/Swiggy/grill/wiki) for getting started with Grill
Check the [Wiki page](https://github.com/singh-jatin28/grill/wiki) for getting started with Grill

## Why write functional tests at all ??
* * *
Expand Down
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Swiggy/grill
module github.com/singh-jatin28/grill

go 1.21

Expand All @@ -22,13 +22,12 @@ require (

require (
dario.cat/mergo v1.0.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.11.5 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.7.18 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
Expand All @@ -37,6 +36,7 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand Down Expand Up @@ -75,14 +75,16 @@ require (
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
72 changes: 6 additions & 66 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/grillclusteredredis/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package grillclusterredis
import (
"context"
"fmt"
"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gr *ClusteredRedis) AssertValue(key, expected string) grill.Assertion {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillclusteredredis/cleaners.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grillclusterredis

import (
"context"
"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gr *ClusteredRedis) FlushDB() grill.Cleaner {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillclusteredredis/clustered_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package grillclusterredis

import (
"context"
"github.com/Swiggy/grill/canned"
"github.com/go-redis/redis/v8"
"github.com/singh-jatin28/grill/canned"
)

type ClusteredRedis struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillclusteredredis/clustered_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package grillclusterredis
import (
"context"
"fmt"
"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/grillclusteredredis/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grillclusterredis

import (
"context"
"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/grillconsul/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package grillconsul
import (
"fmt"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gc *Consul) AssertValue(key, expected string) grill.Assertion {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillconsul/cleaners.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grillconsul

import "github.com/Swiggy/grill"
import "github.com/singh-jatin28/grill"

func (gc *Consul) DeleteAllKeys() grill.Cleaner {
return grill.CleanerFunc(func() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillconsul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grillconsul

import (
"context"
"github.com/Swiggy/grill/canned"
"github.com/singh-jatin28/grill/canned"

"github.com/hashicorp/consul/api"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillconsul/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"testing"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func Test_GrillRedis(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillconsul/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"log"
"os"

"github.com/Swiggy/grill"
"github.com/hashicorp/consul/api"
"github.com/singh-jatin28/grill"
)

// Reads a csv file and puts them in Consul.
Expand Down
2 changes: 1 addition & 1 deletion pkg/grilldynamo/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"reflect"

"github.com/Swiggy/grill"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/singh-jatin28/grill"
)

func (gd *Dynamo) AssertScanCount(input *dynamodb.ScanInput, expectedCount int) grill.Assertion {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grilldynamo/cleaners.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package grilldynamo

import (
"github.com/Swiggy/grill"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/singh-jatin28/grill"
)

func (gd *Dynamo) DeleteItem(tableName string, key map[string]*dynamodb.AttributeValue) grill.Cleaner {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grilldynamo/dynamo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grilldynamo

import (
"context"
"github.com/Swiggy/grill/canned"
"github.com/singh-jatin28/grill/canned"

"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/grilldynamo/dynamo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"

"github.com/Swiggy/grill"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/singh-jatin28/grill"
)

type testVal struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/grilldynamo/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"encoding/json"
"os"

"github.com/Swiggy/grill"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/singh-jatin28/grill"
)

func (gd *Dynamo) CreateTable(req *dynamodb.CreateTableInput) grill.Stub {
Expand All @@ -32,9 +32,9 @@ func (gd *Dynamo) PutItem(tableName string, item map[string]*dynamodb.AttributeV
// Each Line represents a new item
//
// Args -
// tableName - table to put data
// filePath - absolute file path.
//
// tableName - table to put data
// filePath - absolute file path.
func (gd *Dynamo) SeedDataFromFile(tableName string, filePath string) grill.Stub {
return grill.StubFunc(func() error {
file, err := os.Open(filePath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillelasticsearch/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/Swiggy/grill"
"github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/singh-jatin28/grill"
"io"
"reflect"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillelasticsearch/cleaners.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package grillelasticsearch

import (
"context"
"github.com/Swiggy/grill"
"github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/singh-jatin28/grill"
)

func (ge *ElasticSearch) DeleteIndices(indices ...string) grill.Cleaner {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillelasticsearch/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package grillelasticsearch

import (
"context"
"github.com/Swiggy/grill/canned"
"github.com/elastic/go-elasticsearch/v7"
"github.com/singh-jatin28/grill/canned"
)

type ElasticSearch struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillelasticsearch/es_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
"testing"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillelasticsearch/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"context"
"fmt"
"github.com/Swiggy/grill"
"github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/singh-jatin28/grill"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/grillgrpc/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package grillgrpc
import (
"fmt"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gg *GRPC) AssertCount(request Request, expectedCount int) grill.Assertion {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillgrpc/cleaners.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grillgrpc

import "github.com/Swiggy/grill"
import "github.com/singh-jatin28/grill"

func (gg *GRPC) ResetAllStubs() grill.Cleaner {
return grill.CleanerFunc(func() error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/grillgrpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"testing"

"github.com/Swiggy/grill/pkg/grillgrpc/hello"
"github.com/singh-jatin28/grill/pkg/grillgrpc/hello"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillgrpc/stubs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package grillgrpc

import (
"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gg *GRPC) Stub(request Request, response Response) grill.Stub {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillhttp/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strings"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gh *HTTP) AssertCount(request *Request, expectedCount int) grill.Assertion {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillhttp/cleaners.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/http"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gh *HTTP) ResetAllStubs() grill.Cleaner {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillhttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grillhttp

import (
"context"
"github.com/Swiggy/grill/canned"
"github.com/singh-jatin28/grill/canned"
)

type HTTP struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillhttp/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"testing"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillhttp/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strings"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gh *HTTP) StubFromJSON(stubStr string) grill.Stub {
Expand Down
6 changes: 3 additions & 3 deletions pkg/grillkafka/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"reflect"
"time"

"github.com/Swiggy/grill"
"github.com/singh-jatin28/grill"
)

func (gk *Kafka) AssertCount(topicName string, expectedCount int) grill.Assertion {
return grill.AssertionFunc(func() error {
group := fmt.Sprintf("%s_%d_%s", "oh_my_test_helper", rand.Intn(1000), time.Now())
consumer, err := gk.NewConsumer(group, topicName, time.Second*5)
consumer, err := gk.NewConsumer(group, topicName, time.Second)
if err != nil {
return err
}
Expand All @@ -33,7 +33,7 @@ func (gk *Kafka) AssertCount(topicName string, expectedCount int) grill.Assertio
func (gk *Kafka) AssertMessageCount(topic string, message Message, expectedCount int) grill.Assertion {
return grill.AssertionFunc(func() error {
group := fmt.Sprintf("%s_%d_%s", "oh_my_test_helper", rand.Intn(1000), time.Now())
consumer, err := gk.NewConsumer(group, topic, time.Second*5)
consumer, err := gk.NewConsumer(group, topic, time.Second)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillkafka/cleaners.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

"github.com/Swiggy/grill"
confluent "github.com/confluentinc/confluent-kafka-go/kafka"
"github.com/singh-jatin28/grill"
)

func (gk *Kafka) DeleteTopics(topics ...string) grill.Cleaner {
Expand Down
2 changes: 1 addition & 1 deletion pkg/grillkafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grillkafka

import (
"context"
"github.com/Swiggy/grill/canned"
"github.com/singh-jatin28/grill/canned"
"time"

confluent "github.com/confluentinc/confluent-kafka-go/kafka"
Expand Down
Loading