package archive import ( "bytes" "os" "path/filepath" "testing" ) // The move archive carries .env byte for byte, so the instance key // lands on the target exactly as the source minted it (L21: the key is the // exact bytes the env file yields). func TestArchiveCarriesTheInstanceKeyByteForByte(t *testing.T) { dir, env := filesFixture(t) body := []byte("CARLOS_ADMIN_TOKEN=t\nCARLOS_INSTANCE_KEY=q+/Zk3vJ0aW1Yx9sR7tUe2oPl4mN8bC6dF5gH0iJ1kA=\n") mustWrite(t, env, body, 0o600) var built bytes.Buffer if _, _, _, err := Build(dir, env, &built); err != nil { t.Fatal(err) } out := filepath.Join(t.TempDir(), "out") outEnv := filepath.Join(t.TempDir(), "out.env") if err := Extract(bytes.NewReader(built.Bytes()), out, outEnv); err != nil { t.Fatal(err) } got, err := os.ReadFile(outEnv) if err != nil || !bytes.Equal(got, body) { t.Fatalf("extracted env differs from the source's: %d bytes, want %d (err %v)", len(got), len(body), err) } }