import { ensure } from "@workshop/shared/utils"
import { setupWebhooks, type User } from "./helpers"

function getEnv(name: string): string {
  const value = process.env[name]
  ensure(value, `Missing env var: ${name}. See .env.example`)
  return value
}

export const corey: User = { token: getEnv("TEST_GITEA_API_TOKEN_COREY"), username: "probablycorey" }
export const spike: User = { token: getEnv("TEST_GITEA_API_TOKEN_SPIKE"), username: "Spike" }
export const coreyRepo = getEnv("TEST_REPO_COREY")
export const spikeRepo = getEnv("TEST_REPO_SPIKE")

const teardown = await setupWebhooks(corey, spike, coreyRepo, spikeRepo)

process.on("beforeExit", () => teardown())
