package main

import (
	"net/http"
	"net/http/httptest"
	"strconv"
	"testing"

	"party.at/party/cmd/party/common"
)

func TestReadIDParam(t *testing.T) {
	const test_id int64 = 3

	r := httptest.NewRequest(http.MethodGet, "/v1/issues/" + strconv.FormatInt(test_id, 10), nil)
	r.SetPathValue("id", "3")

	id, err := common.ReadIDParam(r)
	if err != nil {
		t.Fatal(err)
	}

	if id != test_id {
		t.Errorf("want %d, got id %d", test_id, id)
	}
}
