package core import ( "bytes" "testing" ) func TestNewRejectsNilWriters(t *testing.T) { t.Run("nil stdout", func(t *testing.T) { app, err := New(nil, &bytes.Buffer{}) if err == nil { t.Fatal("expected error for nil stdout") } if app != nil { t.Fatal("expected nil app for nil stdout") } }) t.Run("nil stderr", func(t *testing.T) { app, err := New(&bytes.Buffer{}, nil) if err == nil { t.Fatal("expected error for nil stderr") } if app != nil { t.Fatal("expected nil app for nil stderr") } }) } func TestDeriveDestination(t *testing.T) { tests := []struct { name string uri string want string }{ {name: "github short", uri: "technicalpickles/pickled-vim", want: "pickled-vim"}, {name: "https", uri: "https://github.com/technicalpickles/pickled-vim.git", want: "pickled-vim"}, {name: "git ssh", uri: "git@github.com:technicalpickles/pickled-vim.git", want: "pickled-vim"}, {name: "file", uri: "file:///tmp/dotfiles.git", want: "dotfiles"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := deriveDestination(tt.uri); got != tt.want { t.Fatalf("deriveDestination(%q) = %q, want %q", tt.uri, got, tt.want) } }) } }