Add Helper test for Windows

This commit is contained in:
William Martin 2024-05-16 17:01:41 +02:00
parent 64d50e6fbc
commit 3803fd04b9

View file

@ -3,6 +3,7 @@ package gitcredentials_test
import (
"context"
"path/filepath"
"runtime"
"testing"
"github.com/cli/cli/v2/git"
@ -135,9 +136,10 @@ func TestConfiguredHelperWithPreexistingHostHelperConfigured(t *testing.T) {
func TestHelperIsOurs(t *testing.T) {
tests := []struct {
name string
cmd string
want bool
name string
cmd string
want bool
windowsOnly bool
}{
{
name: "blank",
@ -164,9 +166,19 @@ func TestHelperIsOurs(t *testing.T) {
cmd: "!/path/to/gh auth",
want: true,
},
{
name: "ours - Windows edition",
cmd: `!'C:\Program Files\GitHub CLI\gh.exe' auth git-credential`,
want: true,
windowsOnly: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.windowsOnly && runtime.GOOS != "windows" {
t.Skip("skipping test on non-Windows platform")
}
h := gitcredentials.Helper{Cmd: tt.cmd}
if got := h.IsOurs(); got != tt.want {
t.Errorf("IsOurs() = %v, want %v", got, tt.want)