github.com/kubeshop/testkube@v1.17.23/test/postman/Testkube-API-Failing.postman_collection.json (about)

     1  {
     2  	"info": {
     3  		"_postman_id": "540fc6ef-8e84-4333-931e-22f0da72112d",
     4  		"name": "Testkube-Sanity-Failing",
     5  		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
     6  	},
     7  	"item": [
     8  		{
     9  			"name": "List tests",
    10  			"event": [
    11  				{
    12  					"listen": "test",
    13  					"script": {
    14  						"exec": [
    15  							"pm.test(\"Status code is 200\", function () {",
    16  							"    pm.response.to.have.status(200);",
    17  							"});",
    18  							"",
    19  							"pm.test(\"Test is on the list\", function () {",
    20  							"    let jsonData = pm.response.json();",
    21  							"    let contains = false;",
    22  							"    for (let i=0; i<jsonData.length; i++) {",
    23  							"        if (jsonData[i].name == pm.environment.get(\"test_name\")) {",
    24  							"            contains = true;",
    25  							"        }",
    26  							"    }",
    27  							"",
    28  							"    pm.expect(contains).to.be.true",
    29  							"});"
    30  						],
    31  						"type": "text/javascript"
    32  					}
    33  				},
    34  				{
    35  					"listen": "prerequest",
    36  					"script": {
    37  						"exec": [
    38  							"console.log(\"uri\", pm.environment.get(\"api_uri\"));",
    39  							"console.log(\"test name\", pm.environment.get(\"test_name\"))",
    40  							"console.log(\"test type\", pm.environment.get(\"test_type\"))",
    41  							"console.log(\"exec name\", pm.environment.get(\"execution_name\"))",
    42  							"",
    43  							""
    44  						],
    45  						"type": "text/javascript"
    46  					}
    47  				}
    48  			],
    49  			"request": {
    50  				"method": "GET",
    51  				"header": [],
    52  				"url": {
    53  					"raw": "{{api_uri}}/v1/tests",
    54  					"host": [
    55  						"{{api_uri}}"
    56  					],
    57  					"path": [
    58  						"v1",
    59  						"tests"
    60  					]
    61  				}
    62  			},
    63  			"response": []
    64  		},
    65  		{
    66  			"name": "Create test with invalid body",
    67  			"event": [
    68  				{
    69  					"listen": "prerequest",
    70  					"script": {
    71  						"exec": [
    72  							"console.log(\"uri\", pm.environment.get(\"api_uri\"));",
    73  							"console.log(\"test name\", pm.environment.get(\"test_name\"))",
    74  							"console.log(\"test type\", pm.environment.get(\"test_type\"))",
    75  							"",
    76  							"",
    77  							"function makeid(length) {",
    78  							"    var result           = '';",
    79  							"    var characters       = 'abcdefghijklmnopqrstuvwxyz0123456789';",
    80  							"    var charactersLength = characters.length;",
    81  							"    for ( var i = 0; i < length; i++ ) {",
    82  							"      result += characters.charAt(Math.floor(Math.random() * ",
    83  							" charactersLength));",
    84  							"   }",
    85  							"   return result;",
    86  							"}",
    87  							"",
    88  							"pm.environment.set(\"test_name\", \"postman-test-\"+makeid(6))"
    89  						],
    90  						"type": "text/javascript"
    91  					}
    92  				},
    93  				{
    94  					"listen": "test",
    95  					"script": {
    96  						"exec": [
    97  							"pm.test(\"Status code is 201\", function () {",
    98  							"    pm.response.to.have.status(201);",
    99  							"});",
   100  							"",
   101  							"pm.test(\"Check if test created successfully\", function () {",
   102  							"    let jsonData = pm.response.json();",
   103  							"    let name = jsonData.metadata.name;",
   104  							"    let testName = pm.environment.get(\"test_name\");",
   105  							"    ",
   106  							"    pm.expect(name).to.eql(testName);",
   107  							"});",
   108  							""
   109  						],
   110  						"type": "text/javascript"
   111  					}
   112  				}
   113  			],
   114  			"protocolProfileBehavior": {
   115  				"disabledSystemHeaders": {}
   116  			},
   117  			"request": {
   118  				"method": "POST",
   119  				"header": [],
   120  				"body": {
   121  					"mode": "raw",
   122  					"raw": "{\n    \"labels\": {\n        \"toDelete\": \"yes\"\n    },\n    \"content\": {\n        \"type\": \"string\",\n        \"data\": \"{\\r\\n\\t\\\"info\\\": {\\r\\n\\t\\t\\\"_postman_id\\\": \\\"3d9a6be2-bd3e-4cf7-89ca-354103aab4a7\\\",\\r\\n\\t\\t\\\"name\\\": \\\"testkube\\\",\\r\\n\\t\\t\\\"schema\\\": \\\"https:\\/\\/schema.getpostman.com\\/json\\/collection\\/v2.1.0\\/collection.json\\\"\\r\\n\\t},\\r\\n\\t\\\"item\\\": [\\r\\n\\t\\t{\\r\\n\\t\\t\\t\\\"name\\\": \\\"Health\\\",\\r\\n\\t\\t\\t\\\"event\\\": [\\r\\n\\t\\t\\t\\t{\\r\\n\\t\\t\\t\\t\\t\\\"listen\\\": \\\"test\\\",\\r\\n\\t\\t\\t\\t\\t\\\"script\\\": {\\r\\n\\t\\t\\t\\t\\t\\t\\\"exec\\\": [\\r\\n\\t\\t\\t\\t\\t\\t\\t\\\"pm.test(\\\\\\\"Status code is 200\\\\\\\", function () {\\\",\\r\\n\\t\\t\\t\\t\\t\\t\\t\\\"    pm.response.to.have.status(200);\\\",\\r\\n\\t\\t\\t\\t\\t\\t\\t\\\"});\\\"\\r\\n\\t\\t\\t\\t\\t\\t],\\r\\n\\t\\t\\t\\t\\t\\t\\\"type\\\": \\\"text\\/javascript\\\"\\r\\n\\t\\t\\t\\t\\t}\\r\\n\\t\\t\\t\\t}\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"request\\\": {\\r\\n\\t\\t\\t\\t\\\"method\\\": \\\"GET\\\",\\r\\n\\t\\t\\t\\t\\\"header\\\": [],\\r\\n\\t\\t\\t\\t\\\"url\\\": {\\r\\n\\t\\t\\t\\t\\t\\\"raw\\\": \\\"{{test_api_uri}}\\/health\\\",\\r\\n\\t\\t\\t\\t\\t\\\"host\\\": [\\r\\n\\t\\t\\t\\t\\t\\t\\\"{{test_api_uri}}\\\"\\r\\n\\t\\t\\t\\t\\t],\\r\\n\\t\\t\\t\\t\\t\\\"path\\\": [\\r\\n\\t\\t\\t\\t\\t\\t\\\"health\\\"\\r\\n\\t\\t\\t\\t\\t]\\r\\n\\t\\t\\t\\t}\\r\\n\\t\\t\\t},\\r\\n\\t\\t\\t\\\"response\\\": []\\r\\n\\t\\t}\\r\\n\\t]\\r\\n}\"\n    }\n}",
   123  					"options": {
   124  						"raw": {
   125  							"language": "json"
   126  						}
   127  					}
   128  				},
   129  				"url": {
   130  					"raw": "{{api_uri}}/v1/tests",
   131  					"host": [
   132  						"{{api_uri}}"
   133  					],
   134  					"path": [
   135  						"v1",
   136  						"tests"
   137  					]
   138  				}
   139  			},
   140  			"response": []
   141  		}
   142  	],
   143  	"event": [
   144  		{
   145  			"listen": "prerequest",
   146  			"script": {
   147  				"type": "text/javascript",
   148  				"exec": [
   149  					""
   150  				]
   151  			}
   152  		},
   153  		{
   154  			"listen": "test",
   155  			"script": {
   156  				"type": "text/javascript",
   157  				"exec": [
   158  					""
   159  				]
   160  			}
   161  		}
   162  	],
   163  	"variable": [
   164  		{
   165  			"key": "test_type",
   166  			"value": "postman/collection",
   167  			"type": "string"
   168  		}
   169  	]
   170  }