MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/buildpacks / TestAdaptEntrypoint

Function TestAdaptEntrypoint

pkg/python/python_test.go:536–598  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

534 }
535}
536
537func TestAdaptEntrypoint(t *testing.T) {
538 testCases := []struct {
539 name string
540 cmd []string
541 scriptCmd []string
542 want []string
543 }{
544 {
545 name: "python",
546 cmd: []string{"python", "main.py"},
547 want: []string{"python", "main.py"},
548 },
549 {
550 name: "python3",
551 cmd: []string{"python3", "main.py"},
552 want: []string{"python3", "main.py"},
553 },
554 {
555 name: "gunicorn",
556 cmd: []string{"gunicorn", "-b", ":8080", "main:app"},
557 want: []string{"python3", "lib/bin/gunicorn", "-b", ":8080", "main:app"},
558 },
559 {
560 name: "uvicorn",
561 cmd: []string{"uvicorn", "main:app", "--port", "8080", "--host", "0.0.0.0"},
562 want: []string{"python3", "lib/bin/uvicorn", "main:app", "--port", "8080", "--host", "0.0.0.0"},
563 },
564 {
565 name: "streamlit",
566 cmd: []string{"streamlit", "run", "main.py", "--server.address", "0.0.0.0", "--server.port", "8080"},
567 want: []string{"python3", "lib/bin/streamlit", "run", "main.py", "--server.address", "0.0.0.0", "--server.port", "8080"},
568 },
569 {
570 name: "adk",
571 cmd: []string{"adk", "api_server", "--port", "8080", "--host", "0.0.0.0"},
572 want: []string{"python3", "lib/bin/adk", "api_server", "--port", "8080", "--host", "0.0.0.0"},
573 },
574 {
575 name: "uv",
576 cmd: []string{"uv", "run", "main.py"},
577 want: []string{"python3", "lib/bin/uv", "run", "main.py"},
578 },
579 {
580 name: "script_cmd_priority",
581 cmd: []string{"uv", "run", "foo"},
582 scriptCmd: []string{"foo"},
583 want: []string{"python3", "lib/bin/foo"},
584 },
585 }
586
587 for _, tc := range testCases {
588 t.Run(tc.name, func(t *testing.T) {
589 ctx := gcp.NewContext(gcp.WithCapability(EntrypointAdapterCapability, &MakerEntrypointAdapter{}))
590 got, err := AdaptEntrypoint(ctx, tc.cmd, tc.scriptCmd)
591 if err != nil {
592 t.Fatalf("AdaptEntrypoint(%v) failed: %v", tc.cmd, err)
593 }

Callers

nothing calls this directly

Calls 1

AdaptEntrypointFunction · 0.85

Tested by

no test coverage detected