Keploy Go-SDK
This is the client SDK for Keploy API testing platform. There are 2 modes:
- Capture mode
- Captures requests, response and all external calls and sends to Keploy server.
- After keploy server removes duplicates, it then runs the request on the API again to identify noisy fields.
- Sends the noisy fields to the keploy server to be saved along with the testcase.
- Test mode
- Fetches testcases for the app from keploy server.
- Calls the API with same request payload in testcase.
- Mocks external calls based on data stored in the testcase.
- Validates the respones and uploads results to the keploy server
Contents
- Installation
- Usage
- Configure
- Supported Routers
- Supported Databases
- Support Clients
Installation
go get -u github.com/keploy/go-sdk
Usage
import(
"github.com/keploy/go-sdk/integrations"
"github.com/keploy/go-sdk/keploy"
)
Create your app instance
kApp := keploy.NewApp("<app_name>", "<license_key>", "<keploy_host>", "app_ip_addr", "app_port")
For example:
kApp := keploy.NewApp("my_app", "adkjhf9adf9adf", "", "0.0.0.0", "8080")
export KEPLOY_SDK_MODE="test"
KEPLOY_SDK_MODE
There are 3 modes:
- Capture: Sets to capture mode.
- Test: Sets to test mode.
- Off: Turns off all the functionality provided by the API
Note: KEPLOY_SDK_MODE
value is case sensitive.
Supported Routers
1. WebGo
WebGoV4
kApp := keploy.NewApp("my_app", "adkjhf9adf9adf", "", "0.0.0.0", "8080")
integrations.WebGoV4(kApp, router)
router.Start()
WebGoV6
kApp := keploy.NewApp("my_app", "adkjhf9adf9adf", "", "0.0.0.0", "8080")
integrations.WebGoV6(kApp, router)
router.Start()
2. Echo
e := echo.New()
kApp := keploy.NewApp("my_app", "adkjhf9adf9adf", "", "0.0.0.0", "8080")
integrations.EchoV4(kApp, e)
e.Start(":8080")
Supported Databases
1. MongoDB
db := client.Database("testDB")
col := integrations.NewMongoDB(db.Collection("Demo-Collection"))
Following operations are supported:
- FindOne - Err and Decode method of mongo.SingleResult
- Find - Next and Decode methods of mongo.cursor
- InsertOne
- InsertMany
- UpdateOne
- UpdateMany
- DeleteOne
- DeleteMany
2. DynamoDB
client := integrations.NewDynamoDB(dynamodb.New(sess))
Following operations are supported:
- QueryWithContext
- GetItemWithContext
- PutItemWithContext
Supported Clients
gRPC
kApp := keploy.NewApp("my_app", "adkjhf9adf9adf", "", "0.0.0.0", "8080")
conn, err := grpc.Dial(address, grpc.WithInsecure(), integrations.WithClientUnaryInterceptor(kApp))
Note: Currently streaming is not yet supported.