1import { describe, expect, it } from "@effect/vitest";
2
3import { releaseChannelOf, releaseResourceAttributes } from "./releaseResource.ts";
4
5describe("releaseResourceAttributes", () => {
6 it.each([
7 ["dev", {}, "dev", "development"],
8 ["stable", {}, "stable", "production"],
9 ["nightly", {}, "nightly", "production"],
10 ["preview", {}, "preview", "staging"],
11 [
12 "stable",
13 { "deployment.environment.name": "staging", "t3code.release.channel": "" },
14 "stable",
15 "staging",
16 ],
17 ] as const)(
18 "%s (operator: %o) reports %s in %s",
19 (channel, operatorAttributes, expectedChannel, environment) => {
20 expect(releaseResourceAttributes(channel, operatorAttributes)).toEqual({
21 "t3code.release.channel": expectedChannel,
22 "deployment.environment.name": environment,
23 });
24 },
25 );
26
27 it.each([
28 ["0.1.2", "stable"],
29 ["0.1.2-nightly.20261025.1", "nightly"],
30 ["0.1.2-preview.20261025.1", "preview"],
31 ["0.1.2-pr.24340.123", "preview"],
32 ] as const)("classifies %s as %s", (version, channel) => {
33 expect(releaseChannelOf(version)).toBe(channel);
34 });
35});