pkg/buildinfo/buildinfo_test.go

package buildinfo

import (
	"strings"
	"testing"
)

func TestThirdPartyLicenseReportVersionAndCoderClassification(t *testing.T) {
	report := ThirdPartyLicenseReport()
	if !strings.HasPrefix(report, "EzAgent "+Version+" — Third-Party Licenses\n") {
		t.Fatalf("report header does not use Version: %q", strings.SplitN(report, "\n", 2)[0])
	}
	if strings.Contains(report, "{{EZAGENT_VERSION}}") {
		t.Fatal("report contains unreplaced version placeholder")
	}
	coderNotices := 0
	for _, line := range strings.Split(report, "\n") {
		if strings.HasPrefix(line, "- github.com/coder/websocket v") {
			coderNotices++
			if !strings.HasSuffix(line, " — ISC") {
				t.Fatalf("Coder websocket classification = %q, want ISC", line)
			}
		}
	}
	if coderNotices != 1 {
		t.Fatalf("Coder websocket notice count = %d, want 1", coderNotices)
	}
}