Skip to content

Commit

Permalink
Merge pull request #189 from pixlise/feature/v4-post-release-fixes
Browse files Browse the repository at this point in the history
Make test deterministic
  • Loading branch information
pnemere authored Mar 25, 2024
2 parents 2da9056 + 12c1030 commit 1430881
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions api/coreg/import_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package coreg

import (
"encoding/json"
"fmt"
"log"

Expand All @@ -14,6 +15,16 @@ func printWarpXform(xform *protos.ImageMatchTransform, name string, err error) {
if b, err := protojson.Marshal(xform); err != nil {
log.Fatalln(err)
} else {
// Proto isn't deterministic, so we read as JSON and write it back out again
var anyJson map[string]interface{}
err = json.Unmarshal(b, &anyJson)
if err != nil {
log.Fatalln(err)
}
b, err = json.MarshalIndent(anyJson, "", " ")
if err != nil {
log.Fatalln(err)
}
fmt.Printf("%v\n", string(b))
}
}
Expand All @@ -33,13 +44,33 @@ func Example_readWarpedImageTransform() {

// Output:
// coreg-40_519-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01-A.png|<nil>
// {"xOffset":40, "yOffset":519, "xScale":4.478153, "yScale":4.478153}
// {
// "xOffset": 40,
// "xScale": 4.478153,
// "yOffset": 519,
// "yScale": 4.478153
// }
// coreg-186_216-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01-A.png|<nil>
// {"xOffset":186, "yOffset":216, "xScale":1.1359178, "yScale":1.1359178}
// {
// "xOffset": 186,
// "xScale": 1.1359178,
// "yOffset": 216,
// "yScale": 1.1359178
// }
// coreg-40_519-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01.png|<nil>
// {"xOffset":40, "yOffset":519, "xScale":4.478153, "yScale":4.478153}
// {
// "xOffset": 40,
// "xScale": 4.478153,
// "yOffset": 519,
// "yScale": 4.478153
// }
// coreg-186_216-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png|<nil>
// {"xOffset":186, "yOffset":216, "xScale":1.1359178, "yScale":1.1359178}
// {
// "xOffset": 186,
// "xScale": 1.1359178,
// "yOffset": 216,
// "yScale": 1.1359178
// }
// |Warped image name does not have expected components
// {}
// |Failed to find GDS file name section in image name: SC3_0921_0748732957_027RASS_N0450000SRLC11373_0000LMJ01. Error: Failed to parse meta from file name
Expand Down

0 comments on commit 1430881

Please sign in to comment.