Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇

944 B
Raw Blame
/*
©AngelaMos | 2026
client_test.go

Tests for PEP 503 package name normalization in client.go

Tests:
  TestNormalizeName - mixed case, underscores, dots, and consecutive separators all normalize to lowercase hyphenated form
*/

package pypi

import (
	"testing"
)

func TestNormalizeName(t *testing.T) {
	t.Parallel()

	tests := []struct {
		input string
		want  string
	}{
		{"requests", "requests"},
		{"Requests", "requests"},
		{"REQUESTS", "requests"},
		{"some-package", "some-package"},
		{"some_package", "some-package"},
		{"some.package", "some-package"},
		{"Some_Package", "some-package"},
		{"my---package", "my-package"},
		{"my__.package", "my-package"},
		{"Flask", "flask"},
	}

	for _, tt := range tests {
		t.Run(tt.input, func(t *testing.T) {
			t.Parallel()

			got := NormalizeName(tt.input)
			if got != tt.want {
				t.Errorf(
					"NormalizeName(%q) = %q, want %q",
					tt.input, got, tt.want,
				)
			}
		})
	}
}