mirror of
https://github.com/git-pkgs/proxy.git
synced 2026-07-06 22:33:19 -04:00
29 lines
704 B
Go
29 lines
704 B
Go
package handler
|
|
|
|
import (
|
|
"log/slog"
|
|
"testing"
|
|
)
|
|
|
|
func TestHexParseTarballFilename(t *testing.T) {
|
|
h := &HexHandler{proxy: &Proxy{Logger: slog.Default()}}
|
|
|
|
tests := []struct {
|
|
filename string
|
|
wantName string
|
|
wantVersion string
|
|
}{
|
|
{"phoenix-1.7.10.tar", "phoenix", "1.7.10"},
|
|
{"ecto-3.11.0.tar", "ecto", "3.11.0"},
|
|
{"phoenix_live_view-0.20.1.tar", "phoenix_live_view", "0.20.1"},
|
|
{"invalid", "", ""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
name, version := h.parseTarballFilename(tt.filename)
|
|
if name != tt.wantName || version != tt.wantVersion {
|
|
t.Errorf("parseTarballFilename(%q) = (%q, %q), want (%q, %q)",
|
|
tt.filename, name, version, tt.wantName, tt.wantVersion)
|
|
}
|
|
}
|
|
}
|