Skip to content

andrarifqi/go-rest-api

Repository files navigation

Overview

This repository contains a Postman collection and environment to validate two scenarios against the GoRest v2 Users API:

  • Scenario 1: Create a user with name, gender, email, status, and verify the returned id is numeric.

  • Scenario 2: Fetch the first user entry and verify the status is either “active” or “inactive.”

The collection includes automated tests written in Postman’s pm.test scripting. You can run the tests in the Postman desktop app or web.

Repository structure

  • Go REST API.postman_collection.json — Postman collection with requests and tests for both scenarios.

  • GoRest Env.postman_environment.json — Postman environment with base_url and token variables.

  • README.md — This file with setup and run instructions.

Prerequisites

  • Postman desktop app installed.

  • GoRest personal access token. Add this as the token variable in the environment.

Setup in Postman (GUI)

  • Open Postman and Import:

  • Click Import and select Go REST API.postman_collection.json and GoRest Env.postman_environment.json.

  • Select environment:

    • In the top-right environment dropdown, choose “GoRest Env.”

    • Configure variables:

    • Save the environment.

  • Run tests in Postman (Collection Runner)

  • In Collections, select “Go REST API” and click Run.

  • Ensure “GoRest Env” is selected as the environment.

  • Click Run Collection. The runner will execute:

    • Scenario 1 - Create User (POST /users): Asserts 201, response contains numeric id, and valid status.

    • Scenario 2 - First User Status (GET /users?per_page=1&page=1): Asserts 200 and first item’s status is “active” or “inactive.”

  • Postman will display pass/fail results for each scripted assertion.

About

Runnable Go REST API test using Postman

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published