1. My Awesome App
  2. Help
  3. Testing Status Page Overview with test_status_overview.go

Testing Status Page Overview with test_status_overview.go

Learn how to use the test_status_overview.go script to validate your AppGram status page API responses and ensure services are properly displayed.

Overview

test_status_overview.go is a simple Go utility that tests the AppGram status page overview API endpoint. This script demonstrates how to programmatically verify that your status page is returning the expected service data.

What This Script Does

  • Connects to the AppGram status page API endpoint
  • Fetches the overview data for a specific status page
  • Parses the JSON response to extract service information
  • Validates that services are properly included in the response

File Structure

package main

import (
    "encoding/json"
    "fmt"
    "log"
    "net/http"
    "time"
)

func main() {
    client := &http.Client{Timeout: 10 * time.Second}
    url := "http://127.0.0.1:3001/api/v1/status-pages/public/aaa94712-bb41-4536-a674-1df42bc06068/status/overview"
    
    resp, err := client.Get(url)
    // ... error handling and response parsing
}

Key Features

1. HTTP Client Configuration

The script uses a 10-second timeout to prevent hanging requests:

client := &http.Client{Timeout: 10 * time.Second}

2. API Endpoint Format

The endpoint follows this pattern:

GET /api/v1/status-pages/public/{status-page-id}/status/overview

3. Response Validation

The script checks for:

  • HTTP 200 status code
  • Valid JSON response
  • Presence of services data in the response

Expected Response Structure

{
  "data": {
    "services": [
      {
        "id": "service-id",
        "name": "Service Name",
        "status": "operational",
        "uptime": 99.99,
        "incidents": []
      }
    ]
  }
}

Usage Instructions

Prerequisites

  • Go 1.19 or later
  • AppGram server running locally or remotely
  • Valid status page ID

Running the Script

cd /path/to/appgram

go run test_status_overview.go

Common Issues

Connection Refused

If you see "connection refused", ensure the AppGram server is running:

./appgram-server

Invalid Status Page ID

Replace the status page ID in the URL with your actual ID. You can find this in your AppGram dashboard under Status Pages.

Timeout Errors

If requests timeout, check:

  • Server is responsive
  • Network connectivity
  • Firewall settings

Customization

Change Environment

To test against production, update the URL:

url := "https://your-domain.com/api/v1/status-pages/public/your-status-page-id/status/overview"

Add More Validation

Extend the script to validate specific service properties:

// Add after services check
for _, service := range services.([]interface{}) {
    s := service.(map[string]interface{})
    if s["status"] != "operational" {
        fmt.Printf("Warning: Service %s has status %s\n", s["name"], s["status"])
    }
}

Integration with CI/CD

Add this script to your CI/CD pipeline to automatically verify status page functionality:

# .github/workflows/test.yml
- name: Test Status Page
  run: go run test_status_overview.go

Related Resources

  • API Endpoints Documentation
  • Setting Up Status Pages
  • Go SDK Examples