| 1076 | } |
| 1077 | |
| 1078 | func TestRejectDropsMatchingLinesFromInput(t *testing.T) { |
| 1079 | t.Parallel() |
| 1080 | input := "This is the first line in the file.\nHello, world.\nThis is another line in the file.\n" |
| 1081 | tcs := []struct { |
| 1082 | reject, want string |
| 1083 | }{ |
| 1084 | { |
| 1085 | reject: "line", |
| 1086 | want: "Hello, world.\n", |
| 1087 | }, |
| 1088 | { |
| 1089 | reject: "another", |
| 1090 | want: "This is the first line in the file.\nHello, world.\n", |
| 1091 | }, |
| 1092 | { |
| 1093 | reject: "definitely won't match any lines", |
| 1094 | want: "This is the first line in the file.\nHello, world.\nThis is another line in the file.\n", |
| 1095 | }, |
| 1096 | } |
| 1097 | for _, tc := range tcs { |
| 1098 | got, err := script.Echo(input).Reject(tc.reject).String() |
| 1099 | if err != nil { |
| 1100 | t.Fatal(err) |
| 1101 | } |
| 1102 | if tc.want != got { |
| 1103 | t.Error(cmp.Diff(tc.want, got)) |
| 1104 | } |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | func TestPostPostsToGivenURLUsingPipeAsRequestBody(t *testing.T) { |
| 1109 | t.Parallel() |