railpack

Configure and troubleshoot Railpack builds, with emphasis on RAILPACK_* environment variables, railpack.json overlays, build-plan inspection, local CLI installation and usage, and local BuildKit containers. Use for Railpack provider configuration, custom install/build/start commands, Mise or Apt packages, build or runtime variables and secrets, generated-plan debugging, BUILDKIT_HOST errors, or running Railpack from a release or source checkout.

Install
npx skills add 'https://github.com/railwayapp/railpack/tree/main/.'
Incomplete bundle · no download
main · 21a254fScanned 2026-09-17

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗

core/plan/command_test.go

core/plan/command_test.goBrowse 1970 files
View on GitHub
← Back to SKILL.md
package plan import (	"encoding/json"	"testing" 	"github.com/stretchr/testify/require") func TestCommandMarshalUnmarshal(t *testing.T) {	tests := []struct {		name            string		command         Command		expectedJSON    string		unmarshalString string	}{		// Exec		{			name:            "exec command without custom name",			command:         NewExecShellCommand("echo hello", ExecOptions{CustomName: "echo hello"}),			expectedJSON:    `{"cmd":"sh -c 'echo hello'","customName":"echo hello"}`,			unmarshalString: "echo hello",		},		{			name:            "exec command with custom name",			command:         NewExecShellCommand("echo hello", ExecOptions{CustomName: "Say Hello"}),			expectedJSON:    `{"cmd":"sh -c 'echo hello'","customName":"Say Hello"}`,			unmarshalString: "RUN#Say Hello:echo hello",		}, 		// Path		{			name:            "path command",			command:         NewPathCommand("/usr/local/bin"),			expectedJSON:    `{"path":"/usr/local/bin"}`,			unmarshalString: "PATH:/usr/local/bin",		}, 		// Copy		{			name:            "copy command",			command:         NewCopyCommand("src.txt", "dst.txt"),			expectedJSON:    `{"src":"src.txt","dest":"dst.txt"}`,			unmarshalString: "COPY:src.txt dst.txt",		}, 		// File		{			name:            "file command without custom name",			command:         NewFileCommand("/etc/conf", "config.yaml"),			expectedJSON:    `{"path":"/etc/conf","name":"config.yaml"}`,			unmarshalString: "FILE:/etc/conf config.yaml",		},		{			name:            "file command with custom name",			command:         NewFileCommand("/etc/conf", "config.yaml", FileOptions{CustomName: "Config File"}),			expectedJSON:    `{"path":"/etc/conf","name":"config.yaml","customName":"Config File"}`,			unmarshalString: "FILE#Config File:/etc/conf config.yaml",		},	} 	for _, tt := range tests {		t.Run(tt.name, func(t *testing.T) {			// Test marshalling to JSON object			data, err := json.Marshal(tt.command)			require.NoError(t, err, "failed to marshal command")			require.Equal(t, string(data), tt.expectedJSON, "marshal result") 			// Test unmarshalling from JSON object			cmd, err := UnmarshalCommand([]byte(tt.expectedJSON))			require.NoError(t, err, "failed to unmarshal JSON command") 			// Marshal again to verify it produces the same result			roundTrip, err := json.Marshal(cmd)			require.NoError(t, err, "failed to marshal unmarshalled command")			require.Equal(t, string(roundTrip), tt.expectedJSON, "round-trip JSON result") 			// Test unmarshalling from string format			if tt.unmarshalString != "" {				cmd, err = UnmarshalCommand([]byte(tt.unmarshalString))				require.NoError(t, err, "failed to unmarshal string command") 				// Marshal to JSON to verify it produces the same object				roundTrip, err = json.Marshal(cmd)				require.NoError(t, err, "failed to marshal string-unmarshalled command")				require.Equal(t, string(roundTrip), tt.expectedJSON, "string unmarshal to JSON result") 			}		})	}}