MCPcopy Create free account
hub / github.com/cli/cli / TestIsRelativePath

Function TestIsRelativePath

internal/attachments/references_test.go:1035–1100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1033}
1034
1035func TestIsRelativePath(t *testing.T) {
1036 tests := []struct {
1037 name string
1038 path string
1039 want bool
1040 windowsOnly bool
1041 }{
1042 {
1043 name: "a file name",
1044 path: "login.png",
1045 want: true,
1046 },
1047 {
1048 name: "a path into a folder",
1049 path: "shots/login.png",
1050 want: true,
1051 },
1052 {
1053 name: "a path that starts with a dot",
1054 path: "./login.png",
1055 want: true,
1056 },
1057 {
1058 name: "a path into the parent folder",
1059 path: "../login.png",
1060 want: true,
1061 },
1062 {
1063 name: "an empty path",
1064 path: "",
1065 want: false,
1066 },
1067 {
1068 name: "a path that starts with a slash",
1069 path: "/login.png",
1070 want: false,
1071 },
1072 {
1073 name: "a drive-relative path names a drive of its own",
1074 path: `C:x`,
1075 want: false,
1076 windowsOnly: true,
1077 },
1078 {
1079 name: "a path rooted on the current drive",
1080 path: `\x`,
1081 want: false,
1082 windowsOnly: true,
1083 },
1084 {
1085 name: "an absolute path with a drive",
1086 path: `C:\x`,
1087 want: false,
1088 windowsOnly: true,
1089 },
1090 }
1091
1092 for _, tt := range tests {

Callers

nothing calls this directly

Calls 4

isRelativePathFunction · 0.85
SkipMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected