Skip to content

Commit

Permalink
Fixed failing unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Sep 9, 2024
1 parent 41ee7a1 commit 5a1ceb5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
29 changes: 22 additions & 7 deletions internal/runbits/buildscript/buildscript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ import (
"github.com/stretchr/testify/require"
)

const testProject = "https://platform.activestate.com/org/project?branch=main&commitID=00000000-0000-0000-0000-000000000000"
const testTime = "2000-01-01T00:00:00.000Z"

func checkoutInfo(project, time string) string {
return "```\n" +
"Project: " + project + "\n" +
"Time: " + time + "\n" +
"```\n"
}

func TestDiff(t *testing.T) {
script, err := buildscript.Unmarshal([]byte(
`at_time = "2000-01-01T00:00:00.000Z"
checkoutInfo(testProject, testTime) + `
runtime = solve(
at_time = at_time,
platforms = [
Expand All @@ -38,7 +48,7 @@ main = runtime`))
// Generate the difference between the modified script and the original expression.
result, err := generateDiff(modifiedScript, script)
require.NoError(t, err)
assert.Equal(t, `at_time = "2000-01-01T00:00:00.000Z"
assert.Equal(t, checkoutInfo(testProject, testTime)+`
runtime = solve(
at_time = at_time,
platforms = [
Expand Down Expand Up @@ -71,11 +81,16 @@ func TestRealWorld(t *testing.T) {
require.NoError(t, err)
result, err := generateDiff(script1, script2)
require.NoError(t, err)
assert.Equal(t, `<<<<<<< local
at_time = "2023-10-16T22:20:29.000Z"
=======
at_time = "2023-08-01T16:20:11.985Z"
>>>>>>> remote
assert.Equal(t,
"```\n"+
"<<<<<<< local\n"+
"Project: https://platform.activestate.com/ActiveState-CLI/Merge?branch=main&commitID=d908a758-6a81-40d4-b0eb-87069cd7f07d\n"+
"Time: 2024-05-10T00:00:13.138Z\n"+
"=======\n"+
"Project: https://platform.activestate.com/ActiveState-CLI/Merge?branch=main&commitID=f3263ee4-ac4c-41ee-b778-2585333f49f7\n"+
"Time: 2023-08-01T16:20:11.985Z\n"+
">>>>>>> remote\n"+
"```\n"+`
runtime = state_tool_artifacts_v1(
build_flags = [
],
Expand Down
8 changes: 6 additions & 2 deletions internal/runbits/buildscript/testdata/buildscript1.as
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
at_time = "2023-10-16T22:20:29.000000Z"
```
Project: https://platform.activestate.com/ActiveState-CLI/Merge?branch=main&commitID=d908a758-6a81-40d4-b0eb-87069cd7f07d
Time: 2024-05-10T00:00:13.138Z
```

runtime = state_tool_artifacts_v1(
build_flags = [
],
Expand All @@ -20,4 +24,4 @@ sources = solve(
solver_version = null
)

main = runtime
main = runtime
8 changes: 6 additions & 2 deletions internal/runbits/buildscript/testdata/buildscript2.as
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
at_time = "2023-08-01T16:20:11.985000Z"
```
Project: https://platform.activestate.com/ActiveState-CLI/Merge?branch=main&commitID=f3263ee4-ac4c-41ee-b778-2585333f49f7
Time: 2023-08-01T16:20:11.985000Z
```

runtime = state_tool_artifacts_v1(
build_flags = [
],
Expand All @@ -20,4 +24,4 @@ sources = solve(
solver_version = null
)

main = runtime
main = runtime

0 comments on commit 5a1ceb5

Please sign in to comment.