(t *testing.T)
| 366 | } |
| 367 | |
| 368 | func TestDeployCmd_Success(t *testing.T) { |
| 369 | celer := newInitializedCeler(t) |
| 370 | |
| 371 | var ( |
| 372 | windowsPlatform = expr.If(os.Getenv("GITHUB_ACTIONS") == "true", "x86_64-windows-msvc-enterprise-14", "x86_64-windows-msvc-community-14") |
| 373 | platform = expr.If(runtime.GOOS == "windows", windowsPlatform, "x86_64-linux-ubuntu-22.04-gcc-11.5.0") |
| 374 | project = "project_test_clean" |
| 375 | ) |
| 376 | |
| 377 | configBuildType := &configureCmd{} |
| 378 | if _, err := runCommand(t, configBuildType.Command(celer), "--build-type=Release"); err != nil { |
| 379 | t.Fatal(err) |
| 380 | } |
| 381 | configPlatform := &configureCmd{} |
| 382 | if _, err := runCommand(t, configPlatform.Command(celer), "--platform="+platform); err != nil { |
| 383 | t.Fatal(err) |
| 384 | } |
| 385 | configProject := &configureCmd{} |
| 386 | if _, err := runCommand(t, configProject.Command(celer), "--project="+project); err != nil { |
| 387 | t.Fatal(err) |
| 388 | } |
| 389 | |
| 390 | // Snapshot file lives under the workspace so it's covered by t.Cleanup |
| 391 | // when the test removes the workspace state next run. |
| 392 | snapshotPath := filepath.Join(t.TempDir(), "deploy-e2e.md") |
| 393 | |
| 394 | cmd := &deployCmd{} |
| 395 | stderr, err := runCommand(t, cmd.Command(celer), |
| 396 | "--force", |
| 397 | "--snapshot="+snapshotPath, |
| 398 | ) |
| 399 | if err != nil { |
| 400 | // stderr carries the real cause (color.PrintError pipes the message |
| 401 | // there, returns ErrSilent). Print it so transient git/network |
| 402 | // failures are debuggable without re-running. |
| 403 | t.Fatalf("deploy should succeed for project %s: %v\nstderr:\n%s", project, err, stderr) |
| 404 | } |
| 405 | |
| 406 | // Successful deploy must produce x264's buildtree (project_test_clean |
| 407 | // has only x264@stable in its ports list). |
| 408 | buildDir := fmt.Sprintf("%s/x264@stable/%s-%s-%s", |
| 409 | dirs.BuildtreesDir, platform, project, celer.BuildType()) |
| 410 | if !fileio.PathExists(buildDir) { |
| 411 | t.Fatalf("x264@stable build dir should exist after deploy: %s", buildDir) |
| 412 | } |
| 413 | |
| 414 | // `--snapshot` must export a markdown file at the given path. |
| 415 | if !fileio.PathExists(snapshotPath) { |
| 416 | t.Fatalf("snapshot file should exist at %s", snapshotPath) |
| 417 | } |
| 418 | |
| 419 | // `resolveAllRefs` always writes a deployment markdown under |
| 420 | // installed/celer/deployments regardless of --snapshot. |
| 421 | deploymentsDir := filepath.Join(dirs.InstalledDir, "celer", "deployments") |
| 422 | if !fileio.PathExists(deploymentsDir) { |
| 423 | t.Fatalf("deployments dir should exist after deploy: %s", deploymentsDir) |
| 424 | } |
| 425 | } |
nothing calls this directly
no test coverage detected