| 1 |
// Copyright 2019 The Go Cloud Development Kit Authors |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
package main |
| 16 |
|
| 17 |
import ( |
| 18 |
"fmt" |
| 19 |
"path/filepath" |
| 20 |
"strings" |
| 21 |
"testing" |
| 22 |
) |
| 23 |
|
| 24 |
func Test(t *testing.T) { |
| 25 |
got, fails, err := run(strings.NewReader(testOutput)) |
| 26 |
if err != nil { |
| 27 |
t.Fatal(err) |
| 28 |
} |
| 29 |
path := filepath.Join("gocloud.dev", "internal", "docstore", "internal", "fields", "TestUnexportedAnonymousNonStruct") |
| 30 |
want := fmt.Sprintf(`Failures (reporting up to 10): |
| 31 |
%s |
| 32 |
ran 6; passed 3; failed 1; skipped 2 (in `, path) |
| 33 |
if !strings.HasPrefix(got, want) { |
| 34 |
t.Errorf("\ngot %s\nwant %s", got, want) |
| 35 |
} |
| 36 |
if !fails { |
| 37 |
t.Error("wanted fails true, got false") |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
const testOutput = `{"Time":"2019-05-09T16:39:56.83133991-04:00","Action":"run","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestFieldsNoTags"} |
| 42 |
{"Time":"2019-05-09T16:39:56.831489481-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestFieldsNoTags","Output":"=== RUN TestFieldsNoTags\n"} |
| 43 |
{"Time":"2019-05-09T16:39:56.831517464-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestFieldsNoTags","Output":"--- PASS: TestFieldsNoTags (0.00s)\n"} |
| 44 |
{"Time":"2019-05-09T16:39:56.831535431-04:00","Action":"pass","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestFieldsNoTags","Elapsed":0} |
| 45 |
{"Time":"2019-05-09T16:39:56.831551807-04:00","Action":"run","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestAgainstJSONEncodingNoTags"} |
| 46 |
{"Time":"2019-05-09T16:39:56.831561396-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestAgainstJSONEncodingNoTags","Output":"=== RUN TestAgainstJSONEncodingNoTags\n"} |
| 47 |
{"Time":"2019-05-09T16:39:56.831573783-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestAgainstJSONEncodingNoTags","Output":"--- PASS: TestAgainstJSONEncodingNoTags (0.00s)\n"} |
| 48 |
{"Time":"2019-05-09T16:39:56.831584528-04:00","Action":"pass","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestAgainstJSONEncodingNoTags","Elapsed":0} |
| 49 |
{"Time":"2019-05-09T16:39:56.844376487-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/drivertest","Output":"? \tgocloud.dev/internal/docstore/drivertest\t[no test files]\n"} |
| 50 |
{"Time":"2019-05-09T16:39:56.844397339-04:00","Action":"skip","Package":"gocloud.dev/internal/docstore/drivertest","Elapsed":0} |
| 51 |
{"Time":"2019-05-09T16:39:56.831666898-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestFieldsWithTags","Output":"--- PASS: TestFieldsWithTags (0.00s)\n"} |
| 52 |
{"Time":"2019-05-09T16:39:56.831677054-04:00","Action":"pass","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestFieldsWithTags","Elapsed":0} |
| 53 |
{"Time":"2019-05-09T16:39:56.831729957-04:00","Action":"output","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestUnexportedAnonymousNonStruct","Output":"=== RUN TestUnexportedAnonymousNonStruct\n"} |
| 54 |
{"Time":"2019-05-09T16:39:56.831759258-04:00","Action":"fail","Package":"gocloud.dev/internal/docstore/internal/fields","Test":"TestUnexportedAnonymousNonStruct","Elapsed":0} |
| 55 |
{"Time":"2019-05-09T16:39:56.873905964-04:00","Action":"skip","Package":"gocloud.dev/internal/docstore/memdocstore","Test":"TestConformance/TypeDrivenCodec","Elapsed":0} |
| 56 |
` |