/usr/share/gocode/src/github.com/smartystreets/goconvey/web/server/parser/package_parser_test.go is in golang-github-smartystreets-goconvey-dev 1.6.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | package parser
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"strings"
"testing"
"github.com/smartystreets/goconvey/convey/reporting"
"github.com/smartystreets/goconvey/web/server/contract"
)
func init() {
log.SetOutput(ioutil.Discard)
}
func TestParsePackage_NoGoFiles_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expected_NoGoFiles.PackageName}
ParsePackageResults(actual, input_NoGoFiles)
assertEqual(t, expected_NoGoFiles, *actual)
}
func TestParsePackage_NoTestFiles_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expected_NoTestFiles.PackageName}
ParsePackageResults(actual, input_NoTestFiles)
assertEqual(t, expected_NoTestFiles, *actual)
}
func TestParsePacakge_NoTestFunctions_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expected_NoTestFunctions.PackageName}
ParsePackageResults(actual, input_NoTestFunctions)
assertEqual(t, expected_NoTestFunctions, *actual)
}
func TestParsePackage_BuildFailed_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expected_BuildFailed_InvalidPackageDeclaration.PackageName}
ParsePackageResults(actual, input_BuildFailed_InvalidPackageDeclaration)
assertEqual(t, expected_BuildFailed_InvalidPackageDeclaration, *actual)
actual = &contract.PackageResult{PackageName: expected_BuildFailed_OtherErrors.PackageName}
ParsePackageResults(actual, input_BuildFailed_OtherErrors)
assertEqual(t, expected_BuildFailed_OtherErrors, *actual)
actual = &contract.PackageResult{PackageName: expected_BuildFailed_ImportCycle.PackageName}
ParsePackageResults(actual, input_BuildFailed_ImportCycle)
assertEqual(t, expected_BuildFailed_ImportCycle, *actual)
actual = &contract.PackageResult{PackageName: expected_BuildFailed_CantFindPackage.PackageName}
ParsePackageResults(actual, input_BuildFailed_CantFindPackage)
assertEqual(t, expected_BuildFailed_CantFindPackage, *actual)
actual = &contract.PackageResult{PackageName: expected_BuildFailed_ConflictingImport.PackageName}
ParsePackageResults(actual, input_BuildFailed_ConfictingImport)
assertEqual(t, expected_BuildFailed_ConflictingImport, *actual)
}
func TestParsePackage_OldSchoolWithFailureOutput_ReturnsCompletePackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedOldSchool_Fails.PackageName}
ParsePackageResults(actual, inputOldSchool_Fails)
assertEqual(t, expectedOldSchool_Fails, *actual)
}
func TestParsePackage_OldSchoolWithSuccessOutput_ReturnsCompletePackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedOldSchool_Passes.PackageName}
ParsePackageResults(actual, inputOldSchool_Passes)
assertEqual(t, expectedOldSchool_Passes, *actual)
}
func TestParsePackage_OldSchoolWithPanicOutput_ReturnsCompletePackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedOldSchool_Panics.PackageName}
ParsePackageResults(actual, inputOldSchool_Panics)
assertEqual(t, expectedOldSchool_Panics, *actual)
}
func TestParsePackage_GoConveyOutput_ReturnsCompletePackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedGoConvey.PackageName}
ParsePackageResults(actual, inputGoConvey)
assertEqual(t, expectedGoConvey, *actual)
}
func TestParsePackage_ActualPackageNameDifferentThanDirectoryName_ReturnsActualPackageName(t *testing.T) {
actual := &contract.PackageResult{PackageName: strings.Replace(expectedGoConvey.PackageName, "examples", "stuff", -1)}
ParsePackageResults(actual, inputGoConvey)
assertEqual(t, expectedGoConvey, *actual)
}
func TestParsePackage_GoConveyOutputMalformed_CausesPanic(t *testing.T) {
defer func() {
if r := recover(); r != nil {
message := fmt.Sprintf("%v", r)
if !strings.Contains(message, "bug report") {
t.Errorf("Should have panicked with a request to file a bug report but we received this error instead: %s", message)
}
} else {
t.Errorf("Should have panicked with a request to file a bug report but we received no error.")
}
}()
actual := &contract.PackageResult{PackageName: expectedGoConvey.PackageName}
ParsePackageResults(actual, inputGoConvey_Malformed)
}
func TestParsePackage_GoConveyWithRandomOutput_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedGoConvey_WithRandomOutput.PackageName}
ParsePackageResults(actual, inputGoConvey_WithRandomOutput)
assertEqual(t, expectedGoConvey_WithRandomOutput, *actual)
}
func TestParsePackage_OldSchoolWithSuccessAndBogusCoverage_ReturnsCompletePackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedOldSchool_PassesButCoverageIsBogus.PackageName}
ParsePackageResults(actual, inputOldSchool_PassesButCoverageIsBogus)
assertEqual(t, expectedOldSchool_PassesButCoverageIsBogus, *actual)
}
func TestParsePackage_NestedTests_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedNestedTests.PackageName}
ParsePackageResults(actual, inputNestedTests)
assertEqual(t, expectedNestedTests, *actual)
}
func TestParsePackage_WithExampleFunctions_ReturnsPackageResult(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedExampleFunctions.PackageName}
ParsePackageResults(actual, inputExampleFunctions)
assertEqual(t, expectedExampleFunctions, *actual)
}
func TestParsePackage_Golang15Output_ShouldNotPanic(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedGolang15.PackageName}
ParsePackageResults(actual, inputGolang15)
assertEqual(t, expectedGolang15, *actual)
}
func assertEqual(t *testing.T, expected, actual interface{}) {
a, _ := json.Marshal(expected)
b, _ := json.Marshal(actual)
if string(a) != string(b) {
t.Errorf(failureTemplate, string(a), string(b))
}
}
const failureTemplate = "Comparison failed:\n Expected: %v\n Actual: %v\n"
const input_NoGoFiles = `can't load package: package github.com/smartystreets/goconvey: no buildable Go source files in /Users/matt/Work/Dev/goconvey/src/github.com/smartystreets/goconvey`
var expected_NoGoFiles = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey",
Outcome: contract.NoGoFiles,
BuildOutput: input_NoGoFiles,
}
const input_NoTestFiles = `? pkg.smartystreets.net/liveaddress-zipapi [no test files]`
var expected_NoTestFiles = contract.PackageResult{
PackageName: "pkg.smartystreets.net/liveaddress-zipapi",
Outcome: contract.NoTestFiles,
BuildOutput: input_NoTestFiles,
}
const input_NoTestFunctions = `testing: warning: no tests to run
PASS
ok github.com/smartystreets/goconvey/scripts 0.011s`
var expected_NoTestFunctions = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/scripts",
Outcome: contract.NoTestFunctions,
BuildOutput: input_NoTestFunctions,
}
const input_BuildFailed_InvalidPackageDeclaration = `
can't load package: package github.com/smartystreets/goconvey/examples:
bowling_game_test.go:9:1: expected 'package', found 'IDENT' asdf
bowling_game_test.go:10:1: invalid package name _
`
var expected_BuildFailed_InvalidPackageDeclaration = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/examples",
Outcome: contract.BuildFailure,
BuildOutput: strings.TrimSpace(input_BuildFailed_InvalidPackageDeclaration),
}
const input_BuildFailed_CantFindPackage = `
bowling_game.go:3:8: cannot find package "format" in any of:
/usr/local/go/src/pkg/format (from $GOROOT)
/Users/mike/work/dev/goconvey/src/format (from $GOPATH)
FAIL github.com/smartystreets/goconvey/examples [setup failed]
`
var expected_BuildFailed_CantFindPackage = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/examples",
Outcome: contract.BuildFailure,
BuildOutput: strings.TrimSpace(input_BuildFailed_CantFindPackage),
}
const input_BuildFailed_ConfictingImport = `
mutustus.go:4:2: found packages e (e.go) and err (prepend.go) in /Users/mike/src/utensils.git/e
`
var expected_BuildFailed_ConflictingImport = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/examples",
Outcome: contract.BuildFailure,
BuildOutput: strings.TrimSpace(input_BuildFailed_ConfictingImport),
}
const input_BuildFailed_OtherErrors = `
# github.com/smartystreets/goconvey/examples
./bowling_game_test.go:22: undefined: game
./bowling_game_test.go:22: cannot assign to game
./bowling_game_test.go:25: undefined: game
./bowling_game_test.go:28: undefined: game
./bowling_game_test.go:33: undefined: game
./bowling_game_test.go:36: undefined: game
./bowling_game_test.go:41: undefined: game
./bowling_game_test.go:42: undefined: game
./bowling_game_test.go:43: undefined: game
./bowling_game_test.go:46: undefined: game
./bowling_game_test.go:46: too many errors
FAIL github.com/smartystreets/goconvey/examples [build failed]
`
var expected_BuildFailed_OtherErrors = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/examples",
Outcome: contract.BuildFailure,
BuildOutput: strings.TrimSpace(input_BuildFailed_OtherErrors),
}
const input_BuildFailed_ImportCycle = `
# github.com/smartystreets/goconvey/t
./t_test.go:23: import "github.com/smartystreets/goconvey/t" while compiling that package (import cycle)
FAIL github.com/smartystreets/goconvey/t [build failed]
`
var expected_BuildFailed_ImportCycle = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/t",
Outcome: contract.BuildFailure,
BuildOutput: strings.TrimSpace(input_BuildFailed_ImportCycle),
}
const inputOldSchool_Passes = `
=== RUN TestOldSchool_Passes
--- PASS: TestOldSchool_Passes (0.02 seconds)
=== RUN TestSkippingTests
--- SKIP: TestSkippingTests (0.00 seconds)
old_school_test.go:8: blah
=== RUN TestOldSchool_PassesWithMessage
--- PASS: TestOldSchool_PassesWithMessage (0.05 seconds)
old_school_test.go:10: I am a passing test.
With a newline.
PASS
coverage: 100.0%% of statements in github.com/smartystreets/goconvey/convey, github.com/smartystreets/goconvey/convey/gotest, github.com/smartystreets/goconvey/convey/reporting
ok github.com/smartystreets/goconvey/webserver/examples 0.018s
`
var expectedOldSchool_Passes = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.018,
Coverage: 100,
Outcome: contract.Passed,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestOldSchool_Passes",
Elapsed: 0.02,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestOldSchool_PassesWithMessage",
Elapsed: 0.05,
Passed: true,
File: "old_school_test.go",
Line: 10,
Message: "old_school_test.go:10: I am a passing test.\nWith a newline.",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestSkippingTests",
Elapsed: 0,
Passed: true,
Skipped: true,
File: "old_school_test.go",
Line: 8,
Message: "old_school_test.go:8: blah",
Stories: []reporting.ScopeResult{},
},
},
}
const inputOldSchool_Fails = `
=== RUN TestOldSchool_Passes
--- PASS: TestOldSchool_Passes (0.01 seconds)
=== RUN TestOldSchool_PassesWithMessage
--- PASS: TestOldSchool_PassesWithMessage (0.03 seconds)
old_school_test.go:10: I am a passing test.
With a newline.
=== RUN TestOldSchool_Failure
--- FAIL: TestOldSchool_Failure (0.06 seconds)
=== RUN TestOldSchool_FailureWithReason
--- FAIL: TestOldSchool_FailureWithReason (0.11 seconds)
old_school_test.go:18: I am a failing test.
FAIL
exit status 1
FAIL github.com/smartystreets/goconvey/webserver/examples 0.017s
`
var expectedOldSchool_Fails = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Outcome: contract.Failed,
Elapsed: 0.017,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestOldSchool_Failure",
Elapsed: 0.06,
Passed: false,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestOldSchool_FailureWithReason",
Elapsed: 0.11,
Passed: false,
File: "old_school_test.go",
Line: 18,
Message: "old_school_test.go:18: I am a failing test.",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestOldSchool_Passes",
Elapsed: 0.01,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestOldSchool_PassesWithMessage",
Elapsed: 0.03,
Passed: true,
File: "old_school_test.go",
Line: 10,
Message: "old_school_test.go:10: I am a passing test.\nWith a newline.",
Stories: []reporting.ScopeResult{},
},
},
}
const inputOldSchool_Panics = `
=== RUN TestOldSchool_Panics
--- FAIL: TestOldSchool_Panics (0.02 seconds)
panic: runtime error: index out of range [recovered]
panic: runtime error: index out of range
goroutine 3 [running]:
testing.func·004()
/usr/local/go/src/pkg/testing/testing.go:348 +0xcd
github.com/smartystreets/goconvey/webserver/examples.TestOldSchool_Panics(0x210292000)
/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/something_test.go:15 +0xec
testing.tRunner(0x210292000, 0x1b09f0)
/usr/local/go/src/pkg/testing/testing.go:353 +0x8a
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:433 +0x86b
goroutine 1 [chan receive]:
testing.RunTests(0x138f38, 0x1b09f0, 0x1, 0x1, 0x1, ...)
/usr/local/go/src/pkg/testing/testing.go:434 +0x88e
testing.Main(0x138f38, 0x1b09f0, 0x1, 0x1, 0x1b7f60, ...)
/usr/local/go/src/pkg/testing/testing.go:365 +0x8a
main.main()
github.com/smartystreets/goconvey/webserver/examples/_test/_testmain.go:43 +0x9a
exit status 2
FAIL github.com/smartystreets/goconvey/webserver/examples 0.014s
`
var expectedOldSchool_Panics = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.014,
Outcome: contract.Panicked,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestOldSchool_Panics",
Elapsed: 0.02,
Passed: false,
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/something_test.go",
Line: 15,
Message: "",
Error: strings.Replace(`panic: runtime error: index out of range [recovered]
panic: runtime error: index out of range
goroutine 3 [running]:
testing.func·004()
/usr/local/go/src/pkg/testing/testing.go:348 +0xcd
github.com/smartystreets/goconvey/webserver/examples.TestOldSchool_Panics(0x210292000)
/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/something_test.go:15 +0xec
testing.tRunner(0x210292000, 0x1b09f0)
/usr/local/go/src/pkg/testing/testing.go:353 +0x8a
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:433 +0x86b
goroutine 1 [chan receive]:
testing.RunTests(0x138f38, 0x1b09f0, 0x1, 0x1, 0x1, ...)
/usr/local/go/src/pkg/testing/testing.go:434 +0x88e
testing.Main(0x138f38, 0x1b09f0, 0x1, 0x1, 0x1b7f60, ...)
/usr/local/go/src/pkg/testing/testing.go:365 +0x8a
main.main()
github.com/smartystreets/goconvey/webserver/examples/_test/_testmain.go:43 +0x9a`, "\u0009", "\t", -1),
Stories: []reporting.ScopeResult{},
},
},
}
const inputGoConvey_Malformed = `
=== RUN TestPassingStory
>->->OPEN-JSON->->->
{
"Title": "A passing story",
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go",
"Line": 11,
"Depth": 0,
"Assertions": [
{
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go",
"Line": 10,
"Failure": "",
;aiwheopinen39 n3902n92m
"Error": null,
"Skipped": false,
"StackTrace": "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/webserver/examples.func·001()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go:10 +0xe3\ngithub.com/smartystreets/goconvey/webserver/examples.TestPassingStory(0x210314000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go:11 +0xec\ntesting.tRunner(0x210314000, 0x21ab10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n"
}
]
},
<-<-<-CLOSE-JSON<-<-<
--- PASS: TestPassingStory (0.01 seconds)
PASS
ok github.com/smartystreets/goconvey/webserver/examples 0.019s
`
const inputGoConvey = `
=== RUN TestPassingStory
>->->OPEN-JSON->->->
{
"Title": "A passing story",
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go",
"Line": 11,
"Depth": 0,
"Assertions": [
{
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go",
"Line": 10,
"Failure": "",
"Error": null,
"Skipped": false,
"StackTrace": "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/webserver/examples.func·001()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go:10 +0xe3\ngithub.com/smartystreets/goconvey/webserver/examples.TestPassingStory(0x210314000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go:11 +0xec\ntesting.tRunner(0x210314000, 0x21ab10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n"
}
]
},
<-<-<-CLOSE-JSON<-<-<
--- PASS: TestPassingStory (0.01 seconds)
PASS
coverage: 75.5%% of statements
ok github.com/smartystreets/goconvey/webserver/examples 0.019s
`
var expectedGoConvey = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.019,
Outcome: contract.Passed,
Coverage: 75.5,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestPassingStory",
Elapsed: 0.01,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{
reporting.ScopeResult{
Title: "A passing story",
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go",
Line: 11,
Depth: 0,
Assertions: []*reporting.AssertionResult{
&reporting.AssertionResult{
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go",
Line: 10,
Failure: "",
Error: nil,
Skipped: false,
StackTrace: "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/webserver/examples.func·001()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go:10 +0xe3\ngithub.com/smartystreets/goconvey/webserver/examples.TestPassingStory(0x210314000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/webserver/examples/old_school_test.go:11 +0xec\ntesting.tRunner(0x210314000, 0x21ab10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n",
},
},
},
},
},
},
}
const inputGoConvey_WithRandomOutput = `
=== RUN TestPassingStory
*** Hello, World! (1) ***
*** Hello, World! (2) ***
*** Hello, World! (3) ***>->->OPEN-JSON->->->
{
"Title": "A passing story",
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
"Line": 16,
"Depth": 0,
"Assertions": [
{
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
"Line": 14,
"Failure": "",
"Error": null,
"Skipped": false,
"StackTrace": "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/web/server/testing.func·001()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:14 +0x186\ngithub.com/smartystreets/goconvey/web/server/testing.TestPassingStory(0x210315000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:16 +0x1b9\ntesting.tRunner(0x210315000, 0x21bb10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n"
}
]
},
<-<-<-CLOSE-JSON<-<-<
*** Hello, World! (4)***
*** Hello, World! (5) ***
>->->OPEN-JSON->->->
{
"Title": "A passing story",
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
"Line": 22,
"Depth": 0,
"Assertions": [
{
"File": "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
"Line": 20,
"Failure": "",
"Error": null,
"Skipped": false,
"StackTrace": "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/web/server/testing.func·002()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:20 +0x186\ngithub.com/smartystreets/goconvey/web/server/testing.TestPassingStory(0x210315000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:22 +0x294\ntesting.tRunner(0x210315000, 0x21bb10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n"
}
]
},
<-<-<-CLOSE-JSON<-<-<
*** Hello, World! (6) ***
--- PASS: TestPassingStory (0.03 seconds)
PASS
coverage: 45.0%% of statements
ok github.com/smartystreets/goconvey/web/server/testing 0.024s
`
var expectedGoConvey_WithRandomOutput = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/web/server/testing",
Elapsed: 0.024,
Outcome: contract.Passed,
Coverage: 45.0,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestPassingStory",
Elapsed: 0.03,
Passed: true,
File: "",
Line: 0,
Message: "*** Hello, World! (1) ***\n*** Hello, World! (2) ***\n*** Hello, World! (3) ***\n*** Hello, World! (4)***\n*** Hello, World! (5) ***\n*** Hello, World! (6) ***",
Stories: []reporting.ScopeResult{
reporting.ScopeResult{
Title: "A passing story",
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
Line: 16,
Depth: 0,
Assertions: []*reporting.AssertionResult{
&reporting.AssertionResult{
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
Line: 14,
Failure: "",
Error: nil,
Skipped: false,
StackTrace: "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/web/server/testing.func·001()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:14 +0x186\ngithub.com/smartystreets/goconvey/web/server/testing.TestPassingStory(0x210315000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:16 +0x1b9\ntesting.tRunner(0x210315000, 0x21bb10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n",
},
},
},
reporting.ScopeResult{
Title: "A passing story",
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
Line: 22,
Depth: 0,
Assertions: []*reporting.AssertionResult{
&reporting.AssertionResult{
File: "/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go",
Line: 20,
Failure: "",
Error: nil,
Skipped: false,
StackTrace: "goroutine 3 [running]:\ngithub.com/smartystreets/goconvey/web/server/testing.func·002()\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:20 +0x186\ngithub.com/smartystreets/goconvey/web/server/testing.TestPassingStory(0x210315000)\n\u0009/Users/mike/work/dev/goconvey/src/github.com/smartystreets/goconvey/web/server/testing/go_test.go:22 +0x294\ntesting.tRunner(0x210315000, 0x21bb10)\n\u0009/usr/local/go/src/pkg/testing/testing.go:353 +0x8a\ncreated by testing.RunTests\n\u0009/usr/local/go/src/pkg/testing/testing.go:433 +0x86b\n",
},
},
},
},
},
},
}
const inputOldSchool_PassesButCoverageIsBogus = `
=== RUN TestOldSchool_Passes
--- PASS: TestOldSchool_Passes (0.02 seconds)
=== RUN TestOldSchool_PassesWithMessage
--- PASS: TestOldSchool_PassesWithMessage (0.05 seconds)
old_school_test.go:10: I am a passing test.
With a newline.
PASS
coverage: bogus%% of statements
ok github.com/smartystreets/goconvey/webserver/examples 0.018s
`
var expectedOldSchool_PassesButCoverageIsBogus = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.018,
Coverage: -1,
Outcome: contract.Passed,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestOldSchool_Passes",
Elapsed: 0.02,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestOldSchool_PassesWithMessage",
Elapsed: 0.05,
Passed: true,
File: "old_school_test.go",
Line: 10,
Message: "old_school_test.go:10: I am a passing test.\nWith a newline.",
Stories: []reporting.ScopeResult{},
},
},
}
const inputNestedTests = `
=== RUN TestNestedTests
=== RUN TestNestedTests_Passes
--- PASS: TestNestedTests_Passes (0.02 seconds)
=== RUN TestNestedTests_Failure
--- FAIL: TestNestedTests_Failure (0.06 seconds)
=== RUN TestNestedTests_FailureWithReason
--- FAIL: TestNestedTests_FailureWithReason (0.11 seconds)
nested_test.go:18: I am a failing test.
=== RUN TestNestedTests_Skipping
--- SKIP: TestNestedTests_Skipping (0.00 seconds)
nested_test.go:8: blah
=== RUN TestNestedTests_PassesWithMessage
--- PASS: TestNestedTests_PassesWithMessage (0.05 seconds)
nested_test.go:10: I am a passing test.
With a newline.
--- FAIL: TestNestedTests (0.25 seconds)
FAIL
exit status 1
FAIL github.com/smartystreets/goconvey/webserver/examples 0.018s
`
var expectedNestedTests = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.018,
Outcome: contract.Failed,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "TestNestedTests",
Elapsed: 0.25,
Passed: false,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestNestedTests_Failure",
Elapsed: 0.06,
Passed: false,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestNestedTests_FailureWithReason",
Elapsed: 0.11,
Passed: false,
File: "nested_test.go",
Line: 18,
Message: "nested_test.go:18: I am a failing test.",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestNestedTests_Passes",
Elapsed: 0.02,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestNestedTests_PassesWithMessage",
Elapsed: 0.05,
Passed: true,
File: "nested_test.go",
Line: 10,
Message: "nested_test.go:10: I am a passing test.\nWith a newline.",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "TestNestedTests_Skipping",
Elapsed: 0.00,
Passed: true,
Skipped: true,
File: "nested_test.go",
Line: 8,
Message: "nested_test.go:8: blah",
Stories: []reporting.ScopeResult{},
},
},
}
const inputExampleFunctions = `
=== RUN Example_Failure
--- FAIL: Example_Failure (0.11 seconds)
got:
actuall output
want:
real output
=== RUN Example_Pass
--- PASS: Example_Pass (0.06 seconds)
FAIL
exit status 1
FAIL github.com/smartystreets/goconvey/webserver/examples 0.18s
`
var expectedExampleFunctions = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.18,
Outcome: contract.Failed,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "Example_Failure",
Elapsed: 0.11,
Passed: false,
File: "",
Line: 0,
Message: "got:\nactuall output\nwant:\nreal output",
Stories: []reporting.ScopeResult{},
},
contract.TestResult{
TestName: "Example_Pass",
Elapsed: 0.06,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
},
}
const inputGolang15 = `
=== RUN Golang15
--- PASS: Golang15 (0.00s)
PASS
ok github.com/smartystreets/goconvey/webserver/examples 0.008s
`
var expectedGolang15 = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.008,
Outcome: contract.Passed,
TestResults: []contract.TestResult{
contract.TestResult{
TestName: "Golang15",
Elapsed: 0.00,
Passed: true,
File: "",
Line: 0,
Message: "",
Stories: []reporting.ScopeResult{},
},
},
}
|