github.com/triarius/goreleaser@v1.12.5/internal/pipe/scoop/scoop_test.go (about) 1 package scoop 2 3 import ( 4 ctx "context" 5 "os" 6 "path/filepath" 7 "testing" 8 9 "github.com/triarius/goreleaser/internal/artifact" 10 "github.com/triarius/goreleaser/internal/client" 11 "github.com/triarius/goreleaser/internal/golden" 12 "github.com/triarius/goreleaser/internal/testlib" 13 "github.com/triarius/goreleaser/pkg/config" 14 "github.com/triarius/goreleaser/pkg/context" 15 "github.com/stretchr/testify/require" 16 ) 17 18 func TestDescription(t *testing.T) { 19 require.NotEmpty(t, Pipe{}.String()) 20 } 21 22 func TestDefault(t *testing.T) { 23 testlib.Mktmp(t) 24 25 ctx := &context.Context{ 26 TokenType: context.TokenTypeGitHub, 27 Config: config.Project{ProjectName: "barr"}, 28 } 29 require.NoError(t, Pipe{}.Default(ctx)) 30 require.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoop.Name) 31 require.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Name) 32 require.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Email) 33 require.NotEmpty(t, ctx.Config.Scoop.CommitMessageTemplate) 34 } 35 36 func Test_doRun(t *testing.T) { 37 folder := testlib.Mktmp(t) 38 file := filepath.Join(folder, "archive") 39 require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644)) 40 41 type args struct { 42 ctx *context.Context 43 client *client.Mock 44 } 45 46 type asserter func(*testing.T, args) 47 type errChecker func(*testing.T, error) 48 shouldErr := func(msg string) errChecker { 49 return func(t *testing.T, err error) { 50 t.Helper() 51 require.Error(t, err) 52 require.EqualError(t, err, msg) 53 } 54 } 55 noAssertions := func(t *testing.T, _ args) { 56 t.Helper() 57 } 58 shouldNotErr := func(t *testing.T, err error) { 59 t.Helper() 60 require.NoError(t, err) 61 } 62 63 tests := []struct { 64 name string 65 args args 66 artifacts []artifact.Artifact 67 assertRunError errChecker 68 assertPublishError errChecker 69 assert asserter 70 }{ 71 { 72 "valid public github", 73 args{ 74 &context.Context{ 75 TokenType: context.TokenTypeGitHub, 76 Git: context.GitInfo{ 77 CurrentTag: "v1.0.1", 78 }, 79 Version: "1.0.1", 80 Config: config.Project{ 81 ProjectName: "run-pipe", 82 Scoop: config.Scoop{ 83 Bucket: config.RepoRef{ 84 Owner: "test", 85 Name: "test", 86 }, 87 Folder: "scoops", 88 Description: "A run pipe test formula", 89 Homepage: "https://github.com/goreleaser", 90 }, 91 }, 92 }, 93 client.NewMock(), 94 }, 95 []artifact.Artifact{ 96 {Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, 97 {Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file}, 98 }, 99 shouldNotErr, 100 shouldNotErr, 101 func(t *testing.T, a args) { 102 t.Helper() 103 require.Equal(t, "scoops/run-pipe.json", a.client.Path) 104 }, 105 }, 106 { 107 "wrap in directory", 108 args{ 109 &context.Context{ 110 TokenType: context.TokenTypeGitHub, 111 Git: context.GitInfo{ 112 CurrentTag: "v1.0.1", 113 }, 114 Version: "1.0.1", 115 Config: config.Project{ 116 ProjectName: "run-pipe", 117 Scoop: config.Scoop{ 118 Bucket: config.RepoRef{ 119 Owner: "test", 120 Name: "test", 121 }, 122 Description: "A run pipe test formula", 123 Homepage: "https://github.com/goreleaser", 124 }, 125 }, 126 }, 127 client.NewMock(), 128 }, 129 []artifact.Artifact{ 130 { 131 Name: "foo_1.0.1_windows_amd64.tar.gz", 132 Goos: "windows", 133 Goarch: "amd64", 134 Goamd64: "v1", 135 Path: file, 136 Extra: map[string]interface{}{ 137 "Wrap": "foo_1.0.1_windows_amd64", 138 }, 139 }, 140 { 141 Name: "foo_1.0.1_windows_386.tar.gz", 142 Goos: "windows", 143 Goarch: "386", 144 Path: file, 145 Extra: map[string]interface{}{ 146 "Wrap": "foo_1.0.1_windows_386", 147 }, 148 }, 149 }, 150 shouldNotErr, 151 shouldNotErr, 152 noAssertions, 153 }, 154 { 155 "valid enterprise github", 156 args{ 157 &context.Context{ 158 TokenType: context.TokenTypeGitHub, 159 Git: context.GitInfo{ 160 CurrentTag: "v1.0.1", 161 }, 162 Version: "1.0.1", 163 Config: config.Project{ 164 GitHubURLs: config.GitHubURLs{Download: "https://api.custom.github.enterprise.com"}, 165 ProjectName: "run-pipe", 166 Scoop: config.Scoop{ 167 Bucket: config.RepoRef{ 168 Owner: "test", 169 Name: "test", 170 }, 171 Description: "A run pipe test formula", 172 Homepage: "https://github.com/goreleaser", 173 }, 174 }, 175 }, 176 client.NewMock(), 177 }, 178 []artifact.Artifact{ 179 {Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, 180 {Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file}, 181 }, 182 shouldNotErr, 183 shouldNotErr, 184 func(t *testing.T, a args) { 185 t.Helper() 186 require.Equal(t, "run-pipe.json", a.client.Path) 187 }, 188 }, 189 { 190 "valid public gitlab", 191 args{ 192 &context.Context{ 193 TokenType: context.TokenTypeGitLab, 194 Git: context.GitInfo{ 195 CurrentTag: "v1.0.1", 196 }, 197 Version: "1.0.1", 198 Config: config.Project{ 199 ProjectName: "run-pipe", 200 Scoop: config.Scoop{ 201 Bucket: config.RepoRef{ 202 Owner: "test", 203 Name: "test", 204 }, 205 Description: "A run pipe test formula", 206 Homepage: "https://gitlab.com/goreleaser", 207 }, 208 }, 209 }, 210 client.NewMock(), 211 }, 212 []artifact.Artifact{ 213 { 214 Name: "foo_1.0.1_windows_amd64.tar.gz", 215 Goos: "windows", 216 Goarch: "amd64", 217 Goamd64: "v1", 218 Path: file, 219 }, 220 { 221 Name: "foo_1.0.1_windows_386.tar.gz", 222 Goos: "windows", 223 Goarch: "386", 224 Path: file, 225 }, 226 }, 227 shouldNotErr, 228 shouldNotErr, 229 noAssertions, 230 }, 231 { 232 "valid enterprise gitlab", 233 args{ 234 &context.Context{ 235 TokenType: context.TokenTypeGitLab, 236 Git: context.GitInfo{ 237 CurrentTag: "v1.0.1", 238 }, 239 Version: "1.0.1", 240 Config: config.Project{ 241 GitHubURLs: config.GitHubURLs{Download: "https://api.custom.gitlab.enterprise.com"}, 242 ProjectName: "run-pipe", 243 Scoop: config.Scoop{ 244 Bucket: config.RepoRef{ 245 Owner: "test", 246 Name: "test", 247 }, 248 Description: "A run pipe test formula", 249 Homepage: "https://gitlab.com/goreleaser", 250 }, 251 }, 252 }, 253 client.NewMock(), 254 }, 255 []artifact.Artifact{ 256 { 257 Name: "foo_1.0.1_windows_amd64.tar.gz", 258 Goos: "windows", 259 Goarch: "amd64", 260 Goamd64: "v1", 261 Path: file, 262 }, 263 { 264 Name: "foo_1.0.1_windows_386.tar.gz", 265 Goos: "windows", 266 Goarch: "386", 267 Path: file, 268 }, 269 }, 270 shouldNotErr, 271 shouldNotErr, 272 noAssertions, 273 }, 274 { 275 "no windows build", 276 args{ 277 &context.Context{ 278 TokenType: context.TokenTypeGitHub, 279 Git: context.GitInfo{ 280 CurrentTag: "v1.0.1", 281 }, 282 Version: "1.0.1", 283 Config: config.Project{ 284 ProjectName: "run-pipe", 285 Scoop: config.Scoop{ 286 Bucket: config.RepoRef{ 287 Owner: "test", 288 Name: "test", 289 }, 290 Description: "A run pipe test formula", 291 Homepage: "https://github.com/goreleaser", 292 }, 293 }, 294 }, 295 client.NewMock(), 296 }, 297 []artifact.Artifact{}, 298 shouldErr(ErrNoWindows.Error()), 299 shouldNotErr, 300 noAssertions, 301 }, 302 { 303 "is draft", 304 args{ 305 &context.Context{ 306 TokenType: context.TokenTypeGitHub, 307 Git: context.GitInfo{ 308 CurrentTag: "v1.0.1", 309 }, 310 Version: "1.0.1", 311 Config: config.Project{ 312 ProjectName: "run-pipe", 313 Release: config.Release{ 314 Draft: true, 315 }, 316 Scoop: config.Scoop{ 317 Bucket: config.RepoRef{ 318 Owner: "test", 319 Name: "test", 320 }, 321 Description: "A run pipe test formula", 322 Homepage: "https://github.com/goreleaser", 323 }, 324 }, 325 }, 326 client.NewMock(), 327 }, 328 []artifact.Artifact{ 329 {Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, 330 {Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file}, 331 }, 332 shouldNotErr, 333 shouldErr("release is marked as draft"), 334 noAssertions, 335 }, 336 { 337 "is prerelease and skip upload set to auto", 338 args{ 339 &context.Context{ 340 TokenType: context.TokenTypeGitHub, 341 Git: context.GitInfo{ 342 CurrentTag: "v1.0.1-pre.1", 343 }, 344 Semver: context.Semver{ 345 Major: 1, 346 Minor: 0, 347 Patch: 1, 348 Prerelease: "-pre.1", 349 }, 350 Version: "1.0.1-pre.1", 351 Config: config.Project{ 352 ProjectName: "run-pipe", 353 Scoop: config.Scoop{ 354 SkipUpload: "auto", 355 Bucket: config.RepoRef{ 356 Owner: "test", 357 Name: "test", 358 }, 359 Description: "A run pipe test formula", 360 Homepage: "https://github.com/goreleaser", 361 }, 362 }, 363 }, 364 client.NewMock(), 365 }, 366 []artifact.Artifact{ 367 {Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, 368 {Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file}, 369 }, 370 shouldNotErr, 371 shouldErr("release is prerelease"), 372 noAssertions, 373 }, 374 { 375 "skip upload set to true", 376 args{ 377 &context.Context{ 378 TokenType: context.TokenTypeGitHub, 379 Git: context.GitInfo{ 380 CurrentTag: "v1.0.1", 381 }, 382 Version: "1.0.1", 383 Config: config.Project{ 384 ProjectName: "run-pipe", 385 Scoop: config.Scoop{ 386 SkipUpload: "true", 387 Bucket: config.RepoRef{ 388 Owner: "test", 389 Name: "test", 390 }, 391 Description: "A run pipe test formula", 392 Homepage: "https://github.com/goreleaser", 393 }, 394 }, 395 }, 396 client.NewMock(), 397 }, 398 []artifact.Artifact{ 399 {Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, 400 {Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file}, 401 }, 402 shouldNotErr, 403 shouldErr("scoop.skip_upload is true"), 404 noAssertions, 405 }, 406 { 407 "release is disabled", 408 args{ 409 &context.Context{ 410 TokenType: context.TokenTypeGitHub, 411 Git: context.GitInfo{ 412 CurrentTag: "v1.0.1", 413 }, 414 Version: "1.0.1", 415 Config: config.Project{ 416 ProjectName: "run-pipe", 417 Release: config.Release{ 418 Disable: true, 419 }, 420 Scoop: config.Scoop{ 421 Bucket: config.RepoRef{ 422 Owner: "test", 423 Name: "test", 424 }, 425 Description: "A run pipe test formula", 426 Homepage: "https://github.com/goreleaser", 427 }, 428 }, 429 }, 430 client.NewMock(), 431 }, 432 []artifact.Artifact{ 433 {Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file}, 434 {Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file}, 435 }, 436 shouldNotErr, 437 shouldErr("release is disabled"), 438 noAssertions, 439 }, 440 { 441 "no archive", 442 args{ 443 &context.Context{ 444 TokenType: context.TokenTypeGitHub, 445 Git: context.GitInfo{ 446 CurrentTag: "v1.0.1", 447 }, 448 Version: "1.0.1", 449 Config: config.Project{ 450 ProjectName: "run-pipe", 451 Scoop: config.Scoop{ 452 Bucket: config.RepoRef{ 453 Owner: "test", 454 Name: "test", 455 }, 456 Description: "A run pipe test formula", 457 Homepage: "https://github.com/goreleaser", 458 }, 459 }, 460 }, 461 client.NewMock(), 462 }, 463 []artifact.Artifact{}, 464 shouldErr(ErrNoWindows.Error()), 465 shouldNotErr, 466 noAssertions, 467 }, 468 } 469 for _, tt := range tests { 470 t.Run(tt.name, func(t *testing.T) { 471 ctx := tt.args.ctx 472 ctx.Artifacts = artifact.New() 473 for _, a := range tt.artifacts { 474 a.Type = artifact.UploadableArchive 475 ctx.Artifacts.Add(&a) 476 } 477 require.NoError(t, Pipe{}.Default(ctx)) 478 479 tt.assertRunError(t, doRun(ctx, tt.args.client)) 480 tt.assertPublishError(t, doPublish(ctx, tt.args.client)) 481 tt.assert(t, tt.args) 482 }) 483 } 484 } 485 486 func Test_buildManifest(t *testing.T) { 487 folder := t.TempDir() 488 file := filepath.Join(folder, "archive") 489 require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644)) 490 491 tests := []struct { 492 desc string 493 ctx *context.Context 494 }{ 495 { 496 "common", 497 &context.Context{ 498 Context: ctx.Background(), 499 TokenType: context.TokenTypeGitHub, 500 Git: context.GitInfo{ 501 CurrentTag: "v1.0.1", 502 }, 503 Version: "1.0.1", 504 Artifacts: artifact.New(), 505 Config: config.Project{ 506 GitHubURLs: config.GitHubURLs{ 507 Download: "https://github.com", 508 }, 509 ProjectName: "run-pipe", 510 Release: config.Release{ 511 GitHub: config.Repo{ 512 Owner: "test", 513 Name: "test", 514 }, 515 }, 516 Scoop: config.Scoop{ 517 Bucket: config.RepoRef{ 518 Owner: "test", 519 Name: "test", 520 }, 521 Description: "A run pipe test formula", 522 Homepage: "https://github.com/goreleaser", 523 Persist: []string{"data", "config", "test.ini"}, 524 }, 525 }, 526 }, 527 }, 528 { 529 "pre-post-install", 530 &context.Context{ 531 Context: ctx.Background(), 532 TokenType: context.TokenTypeGitHub, 533 Git: context.GitInfo{ 534 CurrentTag: "v1.0.1", 535 }, 536 Version: "1.0.1", 537 Artifacts: artifact.New(), 538 Config: config.Project{ 539 GitHubURLs: config.GitHubURLs{ 540 Download: "https://github.com", 541 }, 542 ProjectName: "run-pipe", 543 Release: config.Release{ 544 GitHub: config.Repo{ 545 Owner: "test", 546 Name: "test", 547 }, 548 }, 549 Scoop: config.Scoop{ 550 Bucket: config.RepoRef{ 551 Owner: "test", 552 Name: "test", 553 }, 554 Description: "A run pipe test formula", 555 Homepage: "https://github.com/goreleaser", 556 Persist: []string{"data", "config", "test.ini"}, 557 PreInstall: []string{"Write-Host 'Running preinstall command'"}, 558 PostInstall: []string{"Write-Host 'Running postinstall command'"}, 559 }, 560 }, 561 }, 562 }, 563 { 564 "url template", 565 &context.Context{ 566 Context: ctx.Background(), 567 TokenType: context.TokenTypeGitHub, 568 Git: context.GitInfo{ 569 CurrentTag: "v1.0.1", 570 }, 571 Version: "1.0.1", 572 Artifacts: artifact.New(), 573 Config: config.Project{ 574 GitHubURLs: config.GitHubURLs{ 575 Download: "https://github.com", 576 }, 577 ProjectName: "run-pipe", 578 Scoop: config.Scoop{ 579 Bucket: config.RepoRef{ 580 Owner: "test", 581 Name: "test", 582 }, 583 Description: "A run pipe test formula", 584 Homepage: "https://github.com/goreleaser", 585 URLTemplate: "http://github.mycompany.com/foo/bar/{{ .Tag }}/{{ .ArtifactName }}", 586 CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}", 587 Persist: []string{"data.cfg", "etc"}, 588 }, 589 }, 590 }, 591 }, 592 { 593 "gitlab url template", 594 &context.Context{ 595 Context: ctx.Background(), 596 TokenType: context.TokenTypeGitLab, 597 Git: context.GitInfo{ 598 CurrentTag: "v1.0.1", 599 }, 600 Version: "1.0.1", 601 Artifacts: artifact.New(), 602 Config: config.Project{ 603 GitLabURLs: config.GitLabURLs{ 604 Download: "https://gitlab.com", 605 }, 606 ProjectName: "run-pipe", 607 Scoop: config.Scoop{ 608 Bucket: config.RepoRef{ 609 Owner: "test", 610 Name: "test", 611 }, 612 Description: "A run pipe test formula", 613 Homepage: "https://gitlab.com/goreleaser", 614 URLTemplate: "http://gitlab.mycompany.com/foo/bar/-/releases/{{ .Tag }}/downloads/{{ .ArtifactName }}", 615 CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}", 616 Persist: []string{"data.cfg", "etc"}, 617 }, 618 }, 619 }, 620 }, 621 } 622 623 for _, tt := range tests { 624 t.Run(tt.desc, func(t *testing.T) { 625 ctx := tt.ctx 626 err := Pipe{}.Default(ctx) 627 require.NoError(t, err) 628 629 cl, err := client.New(ctx) 630 require.NoError(t, err) 631 require.NoError(t, Pipe{}.Default(ctx)) 632 633 mf, err := dataFor(ctx, cl, []*artifact.Artifact{ 634 { 635 Name: "foo_1.0.1_windows_amd64.tar.gz", 636 Goos: "windows", 637 Goarch: "amd64", 638 Goamd64: "v1", 639 Path: file, 640 Extra: map[string]interface{}{ 641 artifact.ExtraBuilds: []*artifact.Artifact{ 642 { 643 Name: "foo.exe", 644 }, 645 { 646 Name: "bar.exe", 647 }, 648 }, 649 }, 650 }, 651 { 652 Name: "foo_1.0.1_windows_arm.tar.gz", 653 Goos: "windows", 654 Goarch: "arm", 655 Path: file, 656 Extra: map[string]interface{}{ 657 artifact.ExtraBuilds: []*artifact.Artifact{ 658 { 659 Name: "foo.exe", 660 }, 661 { 662 Name: "bar.exe", 663 }, 664 }, 665 }, 666 }, 667 { 668 Name: "foo_1.0.1_windows_386.tar.gz", 669 Goos: "windows", 670 Goarch: "386", 671 Path: file, 672 Extra: map[string]interface{}{ 673 artifact.ExtraBuilds: []*artifact.Artifact{ 674 { 675 Name: "foo.exe", 676 }, 677 { 678 Name: "bar.exe", 679 }, 680 }, 681 }, 682 }, 683 }) 684 require.NoError(t, err) 685 686 out, err := doBuildManifest(mf) 687 require.NoError(t, err) 688 689 golden.RequireEqualJSON(t, out.Bytes()) 690 }) 691 } 692 } 693 694 func getScoopPipeSkipCtx(folder string) (*context.Context, string) { 695 ctx := &context.Context{ 696 Git: context.GitInfo{ 697 CurrentTag: "v1.0.1", 698 }, 699 Version: "1.0.1", 700 Artifacts: artifact.New(), 701 Config: config.Project{ 702 Dist: folder, 703 ProjectName: "run-pipe", 704 Scoop: config.Scoop{ 705 Bucket: config.RepoRef{ 706 Owner: "test", 707 Name: "test", 708 }, 709 Description: "A run pipe test formula", 710 Homepage: "https://github.com/goreleaser", 711 Name: "run-pipe", 712 }, 713 }, 714 } 715 716 path := filepath.Join(folder, "bin.tar.gz") 717 718 ctx.Artifacts.Add(&artifact.Artifact{ 719 Name: "bin.tar.gz", 720 Path: path, 721 Goos: "windows", 722 Goarch: "amd64", 723 Goamd64: "v1", 724 Type: artifact.UploadableArchive, 725 Extra: map[string]interface{}{ 726 artifact.ExtraID: "foo", 727 artifact.ExtraFormat: "tar.gz", 728 }, 729 }) 730 ctx.Artifacts.Add(&artifact.Artifact{ 731 Name: "ignored.tar.gz", 732 Path: path, 733 Goos: "windows", 734 Goarch: "amd64", 735 Goamd64: "v3", 736 Type: artifact.UploadableArchive, 737 Extra: map[string]interface{}{ 738 artifact.ExtraID: "foo", 739 artifact.ExtraFormat: "tar.gz", 740 }, 741 }) 742 743 return ctx, path 744 } 745 746 func TestRunPipeScoopWithSkipUpload(t *testing.T) { 747 folder := t.TempDir() 748 ctx, path := getScoopPipeSkipCtx(folder) 749 ctx.Config.Scoop.SkipUpload = "true" 750 751 f, err := os.Create(path) 752 require.NoError(t, err) 753 require.NoError(t, f.Close()) 754 755 cli := client.NewMock() 756 require.NoError(t, Pipe{}.Default(ctx)) 757 require.NoError(t, doRun(ctx, cli)) 758 require.EqualError(t, doPublish(ctx, cli), `scoop.skip_upload is true`) 759 760 distFile := filepath.Join(folder, ctx.Config.Scoop.Name+".json") 761 _, err = os.Stat(distFile) 762 require.NoError(t, err, "file should exist: "+distFile) 763 } 764 765 func TestWrapInDirectory(t *testing.T) { 766 folder := t.TempDir() 767 file := filepath.Join(folder, "archive") 768 require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644)) 769 ctx := &context.Context{ 770 TokenType: context.TokenTypeGitLab, 771 Git: context.GitInfo{ 772 CurrentTag: "v1.0.1", 773 }, 774 Version: "1.0.1", 775 Artifacts: artifact.New(), 776 Config: config.Project{ 777 GitLabURLs: config.GitLabURLs{ 778 Download: "https://gitlab.com", 779 }, 780 ProjectName: "run-pipe", 781 Scoop: config.Scoop{ 782 Bucket: config.RepoRef{ 783 Owner: "test", 784 Name: "test", 785 }, 786 Description: "A run pipe test formula", 787 Homepage: "https://gitlab.com/goreleaser", 788 URLTemplate: "http://gitlab.mycompany.com/foo/bar/-/releases/{{ .Tag }}/downloads/{{ .ArtifactName }}", 789 CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}", 790 Persist: []string{"data.cfg", "etc"}, 791 }, 792 }, 793 } 794 require.NoError(t, Pipe{}.Default(ctx)) 795 cl, err := client.New(ctx) 796 require.NoError(t, err) 797 mf, err := dataFor(ctx, cl, []*artifact.Artifact{ 798 { 799 Name: "foo_1.0.1_windows_amd64.tar.gz", 800 Goos: "windows", 801 Goarch: "amd64", 802 Goamd64: "v1", 803 Path: file, 804 Extra: map[string]interface{}{ 805 artifact.ExtraWrappedIn: "foo_1.0.1_windows_amd64", 806 artifact.ExtraBuilds: []*artifact.Artifact{ 807 { 808 Name: "foo.exe", 809 }, 810 { 811 Name: "bar.exe", 812 }, 813 }, 814 }, 815 }, 816 }) 817 require.NoError(t, err) 818 819 out, err := doBuildManifest(mf) 820 require.NoError(t, err) 821 golden.RequireEqualJSON(t, out.Bytes()) 822 } 823 824 func TestSkip(t *testing.T) { 825 t.Run("skip", func(t *testing.T) { 826 require.True(t, Pipe{}.Skip(context.New(config.Project{}))) 827 }) 828 829 t.Run("dont skip", func(t *testing.T) { 830 ctx := context.New(config.Project{ 831 Scoop: config.Scoop{ 832 Bucket: config.RepoRef{ 833 Name: "a", 834 }, 835 }, 836 }) 837 require.False(t, Pipe{}.Skip(ctx)) 838 }) 839 }