(t *testing.T)
| 654 | } |
| 655 | |
| 656 | func TestActionRolloutCommand(t *testing.T) { |
| 657 | t.Parallel() |
| 658 | |
| 659 | t.Run("BasicRollout", func(t *testing.T) { |
| 660 | t.Parallel() |
| 661 | a := require.New(t) |
| 662 | ctx := context.Background() |
| 663 | ctl := &controller{} |
| 664 | |
| 665 | ctx, err := ctl.StartServerWithExternalPg(ctx) |
| 666 | a.NoError(err) |
| 667 | defer ctl.Close(ctx) |
| 668 | |
| 669 | // Create test database |
| 670 | database := ctl.createTestDatabase(ctx, t) |
| 671 | |
| 672 | // Create test data directory and migration file |
| 673 | testDataDir := t.TempDir() |
| 674 | migrationContent := `CREATE TABLE users ( |
| 675 | id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 676 | username TEXT NOT NULL UNIQUE, |
| 677 | created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP |
| 678 | );` |
| 679 | migrationFile := filepath.Join(testDataDir, "00001_create_users.sql") |
| 680 | err = os.WriteFile(migrationFile, []byte(migrationContent), 0644) |
| 681 | a.NoError(err) |
| 682 | |
| 683 | // Create output file |
| 684 | outputFile := filepath.Join(t.TempDir(), "rollout-output.json") |
| 685 | |
| 686 | // Execute rollout |
| 687 | result, err := executeActionCommand(ctx, |
| 688 | "rollout", |
| 689 | "--url", ctl.rootURL, |
| 690 | "--service-account", "demo@example.com", |
| 691 | "--service-account-secret", "1024bytebase", |
| 692 | "--project", ctl.project.Name, |
| 693 | "--targets", database.Name, |
| 694 | "--file-pattern", migrationFile, |
| 695 | "--target-stage", "environments/prod", |
| 696 | "--output", outputFile, |
| 697 | ) |
| 698 | |
| 699 | a.NoError(err, "Rollout command should succeed") |
| 700 | |
| 701 | // E2E Verification: Check server state for complete rollout lifecycle |
| 702 | |
| 703 | // 1. Verify plan was created |
| 704 | plans, err := ctl.planServiceClient.ListPlans(ctx, connect.NewRequest(&v1pb.ListPlansRequest{ |
| 705 | Parent: ctl.project.Name, |
| 706 | })) |
| 707 | a.NoError(err) |
| 708 | a.NotEmpty(plans.Msg.Plans, "Expected plan to be created") |
| 709 | plan := plans.Msg.Plans[0] |
| 710 | |
| 711 | // 2. Verify release was created with correct title |
| 712 | releases, err := ctl.releaseServiceClient.ListReleases(ctx, connect.NewRequest(&v1pb.ListReleasesRequest{ |
| 713 | Parent: ctl.project.Name, |
nothing calls this directly
no test coverage detected