diff --git a/order-service/db/db.go b/order-service/db/db.go index 2aa6fd3..8d3f35e 100644 --- a/order-service/db/db.go +++ b/order-service/db/db.go @@ -4,13 +4,18 @@ import ( "context" "fmt" "log" + "os" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) func Init() *mongo.Database { - clientOption := options.Client().ApplyURI("mongodb://mongo:27019/") + mongoURI := os.Getenv("MONGO_URI") + if mongoURI == "" { + log.Fatal("failed to get env") + } + clientOption := options.Client().ApplyURI(mongoURI) client, err := mongo.Connect(context.Background(), clientOption) if err != nil { log.Fatal("failed to connect to database") diff --git a/order-service/docker-compose.yml b/order-service/docker-compose.yml index f710373..792806e 100644 --- a/order-service/docker-compose.yml +++ b/order-service/docker-compose.yml @@ -1,14 +1,14 @@ services: mongo: - container_name: mongo + container_name: mongo-order image: mongo:latest restart: always ports: - - "27020:27017" + - "27017:27017" goapp: build: . - container_name: goapp + container_name: goapp-order ports: - "8083:8083" depends_on: diff --git a/order-service/internal/data/data.go b/order-service/internal/data/data.go index 700ecbb..7a87bce 100644 --- a/order-service/internal/data/data.go +++ b/order-service/internal/data/data.go @@ -3,6 +3,7 @@ package data import ( "context" "harshy/internal/models" + "log" "time" "go.mongodb.org/mongo-driver/bson" @@ -22,8 +23,15 @@ func NewOrderData(db *mongo.Database) *OrderData { func (o *OrderData) CreateOrder(ctx context.Context, order *models.Order) error { order.CreatedAt = time.Now() - _, err := o.Collection.InsertOne(ctx, order) - return err + result, err := o.Collection.InsertOne(ctx, order) + if err != nil { + log.Printf("Failed to insert order: %v", err) // Log the error for debugging + return err // Return the error for further handling + } + // Retrieve the generated ID from the result and update the order object + order.Id = result.InsertedID.(primitive.ObjectID) + + return nil // Return nil if the operation was successful } func (o *OrderData) GetOrderByUserId(ctx context.Context, userId primitive.ObjectID) ([]*models.Order, error) { @@ -49,7 +57,7 @@ func (o *OrderData) GetOrderByUserId(ctx context.Context, userId primitive.Objec func (o *OrderData) GetOrderById(ctx context.Context, id primitive.ObjectID) (*models.Order, error) { var order models.Order - err := o.Collection.FindOne(ctx, bson.M{"id": id}).Decode(&order) + err := o.Collection.FindOne(ctx, bson.M{"_id": id}).Decode(&order) if err != nil { return nil, err } diff --git a/order-service/internal/models/model.go b/order-service/internal/models/model.go index c0ee746..5135767 100644 --- a/order-service/internal/models/model.go +++ b/order-service/internal/models/model.go @@ -7,7 +7,7 @@ import ( ) type Order struct { - Id primitive.ObjectID `json:"id"` + Id primitive.ObjectID `json:"id" bson:"_id,omitempty"` UserID primitive.ObjectID `json:"userid"` Items []OrderItem `json:"items"` TotalAmount float64 `json:"totalamount"` diff --git a/order-service/keploy.yml b/order-service/keploy.yml new file mode 100755 index 0000000..5ea4551 --- /dev/null +++ b/order-service/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: order-service +command: docker compose up --build +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: goapp +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/order-service/keploy/.gitignore b/order-service/keploy/.gitignore new file mode 100644 index 0000000..5137843 --- /dev/null +++ b/order-service/keploy/.gitignore @@ -0,0 +1,2 @@ + +/reports/ diff --git a/order-service/keploy/test-set-0/mocks.yaml b/order-service/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..aac3b80 --- /dev/null +++ b/order-service/keploy/test-set-0/mocks.yaml @@ -0,0 +1,210 @@ +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-0 +spec: + metadata: + operation: '{ OpQuery flags: [SecondaryOK], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"isMaster": {"$numberInt":"1"},"helloOk": true,"compression": [],"client": {"driver": {"name": "mongo-go-driver","version": "1.17.0"},"os": {"type": "linux","architecture": "amd64"},"platform": "go1.22.2","env": {"container": {"runtime": "docker"}}}}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 276 + requestId: 4 + responseTo: 0 + Opcode: 2004 + message: + flags: 4 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"isMaster":{"$numberInt":"1"},"helloOk":true,"compression":[],"client":{"driver":{"name":"mongo-go-driver","version":"1.17.0"},"os":{"type":"linux","architecture":"amd64"},"platform":"go1.22.2","env":{"container":{"runtime":"docker"}}}}' + return_fields_selector: "" + responses: + - header: + length: 329 + requestId: 3 + responseTo: 4 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"670d4e98bdbb84651f26570c"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1728925376990"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' + read_delay: 572654 + created: 1728925376 + reqTimestampMock: 2024-10-14T17:02:56.990604187Z + resTimestampMock: 2024-10-14T17:02:56.99141024Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-1 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 62 + requestId: 8 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }' + checksum: 0 + read_delay: 10000998367 + responses: + - header: + length: 323 + requestId: 4 + responseTo: 8 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"helloOk":true,"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"670d4eb607ab93fb504a3b50"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1728925386995"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 569431 + created: 1728925386 + reqTimestampMock: 2024-10-14T17:03:06.994912731Z + resTimestampMock: 2024-10-14T17:03:06.995729522Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-2 +spec: + metadata: + operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"helloOk":true,"topologyVersion":{"processId":{"$oid":"670d4e98bdbb84651f26570c"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberLong":"10000"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 148 + requestId: 5 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 65536 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"helloOk":true,"topologyVersion":{"processId":{"$oid":"670d4e98bdbb84651f26570c"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberLong":"10000"},"$db":"admin"} }' + checksum: 0 + read_delay: 262059 + responses: + - header: + length: 323 + requestId: 4 + responseTo: 5 + Opcode: 2013 + message: + flagBits: 2 + sections: + - '{ SectionSingle msg: {"helloOk":true,"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"670d4e98bdbb84651f26570c"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1728925387000"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 10008715773 + created: 1728925387 + reqTimestampMock: 2024-10-14T17:02:56.991787579Z + resTimestampMock: 2024-10-14T17:03:07.000697955Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-3 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"orders","ordered":true,"lsid":{"id":{"$binary":{"base64":"/GB49cb7RFupIvvofoPT9g==","subType":"04"}}},"$db":"Testing"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"670d4fabc4d64c18ca811383"},"userid":{"$oid":"650f1b9b9b5b9f0d5c1a3a8b"},"items":[{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8c"},"product_name":"Laptop","quantity":{"$numberInt":"1"},"price":{"$numberDouble":"1200.5"}},{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8d"},"product_name":"Mouse","quantity":{"$numberInt":"2"},"price":{"$numberDouble":"25.0"}}],"totalamount":{"$numberDouble":"1250.5"},"createdat":{"$date":{"$numberLong":"1728925611068"}},"shippinginfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}} ] }], checksum: 0 }' + requests: + - header: + length: 505 + requestId: 31 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"insert":"orders","ordered":true,"lsid":{"id":{"$binary":{"base64":"/GB49cb7RFupIvvofoPT9g==","subType":"04"}}},"$db":"Testing"} }' + - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"670d4fabc4d64c18ca811383"},"userid":{"$oid":"650f1b9b9b5b9f0d5c1a3a8b"},"items":[{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8c"},"product_name":"Laptop","quantity":{"$numberInt":"1"},"price":{"$numberDouble":"1200.5"}},{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8d"},"product_name":"Mouse","quantity":{"$numberInt":"2"},"price":{"$numberDouble":"25.0"}}],"totalamount":{"$numberDouble":"1250.5"},"createdat":{"$date":{"$numberLong":"1728925611068"}},"shippinginfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}} ] }' + checksum: 0 + read_delay: 389644 + responses: + - header: + length: 45 + requestId: 28 + responseTo: 31 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 20220321 + created: 1728925611 + reqTimestampMock: 2024-10-14T17:06:51.075076756Z + resTimestampMock: 2024-10-14T17:06:51.095654303Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-4 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"orders","filter":{"_id":{"$oid":"670d4fabc4d64c18ca811383"}},"limit":{"$numberLong":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"/GB49cb7RFupIvvofoPT9g==","subType":"04"}}},"$db":"Testing"} }], checksum: 0 }' + requests: + - header: + length: 155 + requestId: 39 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"orders","filter":{"_id":{"$oid":"670d4fabc4d64c18ca811383"}},"limit":{"$numberLong":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"/GB49cb7RFupIvvofoPT9g==","subType":"04"}}},"$db":"Testing"} }' + checksum: 0 + read_delay: 51218935045 + responses: + - header: + length: 488 + requestId: 34 + responseTo: 39 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"670d4fabc4d64c18ca811383"},"userid":{"$oid":"650f1b9b9b5b9f0d5c1a3a8b"},"items":[{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8c"},"product_name":"Laptop","quantity":{"$numberInt":"1"},"price":{"$numberDouble":"1200.5"}},{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8d"},"product_name":"Mouse","quantity":{"$numberInt":"2"},"price":{"$numberDouble":"25.0"}}],"totalamount":{"$numberDouble":"1250.5"},"createdat":{"$date":{"$numberLong":"1728925611068"}},"shippinginfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}}],"id":{"$numberLong":"0"},"ns":"Testing.orders"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 896266 + created: 1728925662 + reqTimestampMock: 2024-10-14T17:07:42.314766471Z + resTimestampMock: 2024-10-14T17:07:42.31598324Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-5 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"orders","filter":{"userid":{"$oid":"650f1b9b9b5b9f0d5c1a3a8b"}},"lsid":{"id":{"$binary":{"base64":"/GB49cb7RFupIvvofoPT9g==","subType":"04"}}},"$db":"Testing"} }], checksum: 0 }' + requests: + - header: + length: 129 + requestId: 43 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"orders","filter":{"userid":{"$oid":"650f1b9b9b5b9f0d5c1a3a8b"}},"lsid":{"id":{"$binary":{"base64":"/GB49cb7RFupIvvofoPT9g==","subType":"04"}}},"$db":"Testing"} }' + checksum: 0 + read_delay: 26239927616 + responses: + - header: + length: 488 + requestId: 42 + responseTo: 43 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"670d4fabc4d64c18ca811383"},"userid":{"$oid":"650f1b9b9b5b9f0d5c1a3a8b"},"items":[{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8c"},"product_name":"Laptop","quantity":{"$numberInt":"1"},"price":{"$numberDouble":"1200.5"}},{"product_id":{"$oid":"650f1b9b9b5b9f0d5c1a3a8d"},"product_name":"Mouse","quantity":{"$numberInt":"2"},"price":{"$numberDouble":"25.0"}}],"totalamount":{"$numberDouble":"1250.5"},"createdat":{"$date":{"$numberLong":"1728925611068"}},"shippinginfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}}],"id":{"$numberLong":"0"},"ns":"Testing.orders"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 2217173 + created: 1728925688 + reqTimestampMock: 2024-10-14T17:08:08.556155817Z + resTimestampMock: 2024-10-14T17:08:08.558675321Z diff --git a/order-service/keploy/test-set-0/tests/test-1.yaml b/order-service/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..548839c --- /dev/null +++ b/order-service/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,46 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8083/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "30" + Content-Type: application/x-www-form-urlencoded + Host: localhost:8083 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: to=%2B918904643525&body=Hwello + timestamp: 2024-10-14T17:04:11.037373118Z + resp: + status_code: 200 + header: + Content-Length: "34" + Content-Type: application/json; charset=utf-8 + Date: Mon, 14 Oct 2024 17:04:11 GMT + body: '{"message":"Order Server is live"}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-14T17:04:13.098843418Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1728925453 +curl: |- + curl --request GET \ + --url http://localhost:8083/ \ + --header 'Host: localhost:8083' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --data "to=%2B918904643525&body=Hwello" diff --git a/order-service/keploy/test-set-0/tests/test-2.yaml b/order-service/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..4e0c7d6 --- /dev/null +++ b/order-service/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,72 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8083/order + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "600" + Content-Type: application/json + Host: localhost:8083 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: | + { + "userid": "650f1b9b9b5b9f0d5c1a3a8b", + "items": [ + { + "product_id": "650f1b9b9b5b9f0d5c1a3a8c", + "product_name": "Laptop", + "quantity": 1, + "price": 1200.50 + }, + { + "product_id": "650f1b9b9b5b9f0d5c1a3a8d", + "product_name": "Mouse", + "quantity": 2, + "price": 25.00 + } + ], + "totalamount": 1250.50, + "shippingInfo": { + "address": "123 Main St", + "city": "New York", + "state": "NY", + "postal_code": "10001", + "country": "USA" + } + } + timestamp: 2024-10-14T17:06:51.067936916Z + resp: + status_code: 200 + header: + Content-Length: "438" + Content-Type: application/json; charset=utf-8 + Date: Mon, 14 Oct 2024 17:06:51 GMT + body: '{"id":"670d4fabc4d64c18ca811383","userid":"650f1b9b9b5b9f0d5c1a3a8b","items":[{"product_id":"650f1b9b9b5b9f0d5c1a3a8c","product_name":"Laptop","quantity":1,"price":1200.5},{"product_id":"650f1b9b9b5b9f0d5c1a3a8d","product_name":"Mouse","quantity":2,"price":25}],"totalamount":1250.5,"createdAt":"2024-10-14T17:06:51.068523763Z","shippingInfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-14T17:06:53.192385884Z + objects: [] + assertions: + noise: + body.createdAt: [] + header.Date: [] + created: 1728925613 +curl: |- + curl --request POST \ + --url http://localhost:8083/order \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8083' \ + --header 'Connection: close' \ + --data "{\n \"userid\": \"650f1b9b9b5b9f0d5c1a3a8b\",\n \"items\": [\n {\n \"product_id\": \"650f1b9b9b5b9f0d5c1a3a8c\",\n \"product_name\": \"Laptop\",\n \"quantity\": 1,\n \"price\": 1200.50\n },\n {\n \"product_id\": \"650f1b9b9b5b9f0d5c1a3a8d\",\n \"product_name\": \"Mouse\",\n \"quantity\": 2,\n \"price\": 25.00\n }\n ],\n \"totalamount\": 1250.50,\n \"shippingInfo\": {\n \"address\": \"123 Main St\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10001\",\n \"country\": \"USA\"\n }\n}\n" diff --git a/order-service/keploy/test-set-0/tests/test-3.yaml b/order-service/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..1ae0dd0 --- /dev/null +++ b/order-service/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,72 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8083/order/670d4fabc4d64c18ca811383 + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "600" + Content-Type: application/json + Host: localhost:8083 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: | + { + "userid": "650f1b9b9b5b9f0d5c1a3a8b", + "items": [ + { + "product_id": "650f1b9b9b5b9f0d5c1a3a8c", + "product_name": "Laptop", + "quantity": 1, + "price": 1200.50 + }, + { + "product_id": "650f1b9b9b5b9f0d5c1a3a8d", + "product_name": "Mouse", + "quantity": 2, + "price": 25.00 + } + ], + "totalamount": 1250.50, + "shippingInfo": { + "address": "123 Main St", + "city": "New York", + "state": "NY", + "postal_code": "10001", + "country": "USA" + } + } + timestamp: 2024-10-14T17:07:42.314019541Z + resp: + status_code: 200 + header: + Content-Length: "432" + Content-Type: application/json; charset=utf-8 + Date: Mon, 14 Oct 2024 17:07:42 GMT + body: '{"id":"670d4fabc4d64c18ca811383","userid":"650f1b9b9b5b9f0d5c1a3a8b","items":[{"product_id":"650f1b9b9b5b9f0d5c1a3a8c","product_name":"Laptop","quantity":1,"price":1200.5},{"product_id":"650f1b9b9b5b9f0d5c1a3a8d","product_name":"Mouse","quantity":2,"price":25}],"totalamount":1250.5,"createdAt":"2024-10-14T17:06:51.068Z","shippingInfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-14T17:07:44.378924573Z + objects: [] + assertions: + noise: + body.createdAt: [] + header.Date: [] + created: 1728925664 +curl: |- + curl --request GET \ + --url http://localhost:8083/order/670d4fabc4d64c18ca811383 \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8083' \ + --header 'Connection: close' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --data "{\n \"userid\": \"650f1b9b9b5b9f0d5c1a3a8b\",\n \"items\": [\n {\n \"product_id\": \"650f1b9b9b5b9f0d5c1a3a8c\",\n \"product_name\": \"Laptop\",\n \"quantity\": 1,\n \"price\": 1200.50\n },\n {\n \"product_id\": \"650f1b9b9b5b9f0d5c1a3a8d\",\n \"product_name\": \"Mouse\",\n \"quantity\": 2,\n \"price\": 25.00\n }\n ],\n \"totalamount\": 1250.50,\n \"shippingInfo\": {\n \"address\": \"123 Main St\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10001\",\n \"country\": \"USA\"\n }\n}\n" diff --git a/order-service/keploy/test-set-0/tests/test-4.yaml b/order-service/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..bd8d3b9 --- /dev/null +++ b/order-service/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,72 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8083/order/user/650f1b9b9b5b9f0d5c1a3a8b + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: close + Content-Length: "600" + Content-Type: application/json + Host: localhost:8083 + User-Agent: Thunder Client (https://www.thunderclient.com) + body: | + { + "userid": "650f1b9b9b5b9f0d5c1a3a8b", + "items": [ + { + "product_id": "650f1b9b9b5b9f0d5c1a3a8c", + "product_name": "Laptop", + "quantity": 1, + "price": 1200.50 + }, + { + "product_id": "650f1b9b9b5b9f0d5c1a3a8d", + "product_name": "Mouse", + "quantity": 2, + "price": 25.00 + } + ], + "totalamount": 1250.50, + "shippingInfo": { + "address": "123 Main St", + "city": "New York", + "state": "NY", + "postal_code": "10001", + "country": "USA" + } + } + timestamp: 2024-10-14T17:08:08.555393096Z + resp: + status_code: 200 + header: + Content-Length: "434" + Content-Type: application/json; charset=utf-8 + Date: Mon, 14 Oct 2024 17:08:08 GMT + body: '[{"id":"670d4fabc4d64c18ca811383","userid":"650f1b9b9b5b9f0d5c1a3a8b","items":[{"product_id":"650f1b9b9b5b9f0d5c1a3a8c","product_name":"Laptop","quantity":1,"price":1200.5},{"product_id":"650f1b9b9b5b9f0d5c1a3a8d","product_name":"Mouse","quantity":2,"price":25}],"totalamount":1250.5,"createdAt":"2024-10-14T17:06:51.068Z","shippingInfo":{"address":"123 Main St","city":"New York","state":"NY","postal_code":"10001","country":"USA"}}]' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-14T17:08:10.581177045Z + objects: [] + assertions: + noise: + body.createdAt: [] + header.Date: [] + created: 1728925690 +curl: |- + curl --request GET \ + --url http://localhost:8083/order/user/650f1b9b9b5b9f0d5c1a3a8b \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Accept: */*' \ + --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8083' \ + --header 'Connection: close' \ + --data "{\n \"userid\": \"650f1b9b9b5b9f0d5c1a3a8b\",\n \"items\": [\n {\n \"product_id\": \"650f1b9b9b5b9f0d5c1a3a8c\",\n \"product_name\": \"Laptop\",\n \"quantity\": 1,\n \"price\": 1200.50\n },\n {\n \"product_id\": \"650f1b9b9b5b9f0d5c1a3a8d\",\n \"product_name\": \"Mouse\",\n \"quantity\": 2,\n \"price\": 25.00\n }\n ],\n \"totalamount\": 1250.50,\n \"shippingInfo\": {\n \"address\": \"123 Main St\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10001\",\n \"country\": \"USA\"\n }\n}\n"