| 1073 | } |
| 1074 | |
| 1075 | func TestIncludesRemote(t *testing.T) { |
| 1076 | enableExperimentForTest(t, &experiments.RemoteTaskfiles, 1) |
| 1077 | |
| 1078 | dir := "testdata/includes_remote" |
| 1079 | os.RemoveAll(filepath.Join(dir, ".task", "remote")) |
| 1080 | |
| 1081 | srv := httptest.NewServer(http.FileServer(http.Dir(dir))) |
| 1082 | defer srv.Close() |
| 1083 | |
| 1084 | tcs := []struct { |
| 1085 | firstRemote string |
| 1086 | secondRemote string |
| 1087 | }{ |
| 1088 | { |
| 1089 | firstRemote: srv.URL + "/first/Taskfile.yml", |
| 1090 | secondRemote: srv.URL + "/first/second/Taskfile.yml", |
| 1091 | }, |
| 1092 | { |
| 1093 | firstRemote: srv.URL + "/first/Taskfile.yml", |
| 1094 | secondRemote: "./second/Taskfile.yml", |
| 1095 | }, |
| 1096 | { |
| 1097 | firstRemote: srv.URL + "/first/", |
| 1098 | secondRemote: srv.URL + "/first/second/", |
| 1099 | }, |
| 1100 | } |
| 1101 | |
| 1102 | taskCalls := []*task.Call{ |
| 1103 | {Task: "first:write-file"}, |
| 1104 | {Task: "first:second:write-file"}, |
| 1105 | } |
| 1106 | |
| 1107 | for i, tc := range tcs { |
| 1108 | t.Run(fmt.Sprint(i), func(t *testing.T) { |
| 1109 | t.Setenv("FIRST_REMOTE_URL", tc.firstRemote) |
| 1110 | t.Setenv("SECOND_REMOTE_URL", tc.secondRemote) |
| 1111 | |
| 1112 | var buff SyncBuffer |
| 1113 | |
| 1114 | // Extract host from server URL for trust testing |
| 1115 | parsedURL, err := url.Parse(srv.URL) |
| 1116 | require.NoError(t, err) |
| 1117 | trustedHost := parsedURL.Host |
| 1118 | |
| 1119 | executors := []struct { |
| 1120 | name string |
| 1121 | executor *task.Executor |
| 1122 | }{ |
| 1123 | { |
| 1124 | name: "online, always download", |
| 1125 | executor: task.NewExecutor( |
| 1126 | task.WithDir(dir), |
| 1127 | task.WithStdout(&buff), |
| 1128 | task.WithStderr(&buff), |
| 1129 | task.WithTimeout(time.Minute), |
| 1130 | task.WithInsecure(true), |
| 1131 | task.WithStdout(&buff), |
| 1132 | task.WithStderr(&buff), |