-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package properties | ||
|
||
import ( | ||
"github.com/tidwall/gjson" | ||
) | ||
|
||
func AltGeometries(body []byte) ([]string, error) { | ||
|
||
rsp := gjson.GetBytes(body, "properties.src:geom_alt") | ||
possible := rsp.Array() | ||
|
||
count := len(possible) | ||
geoms := make([]string, count) | ||
|
||
for idx, r := range possible { | ||
geoms[idx] = r.String() | ||
} | ||
|
||
return geoms, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package properties | ||
|
||
import ( | ||
"io" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
var valid_geoms = strings.NewReader(`{"properties":{"src:geom_alt": ["quattroshapes","debug"] }}`) | ||
|
||
var missing_geoms = strings.NewReader(`{"properties":{ }}`) | ||
|
||
func TestValidAltGeoms(t *testing.T) { | ||
|
||
body, err := io.ReadAll(valid_geoms) | ||
|
||
if err != nil { | ||
t.Fatalf("Failed to read data (valid), %v", err) | ||
} | ||
|
||
alt_geoms, err := AltGeometries(body) | ||
|
||
if err != nil { | ||
t.Fatalf("Expect data (valid) failed") | ||
} | ||
|
||
if alt_geoms[0] != "quattroshapes" { | ||
t.Fatal("Invalid alt geometry (valid)") | ||
} | ||
|
||
} | ||
|
||
func TestMissingGeoms(t *testing.T) { | ||
|
||
body, err := io.ReadAll(missing_geoms) | ||
|
||
if err != nil { | ||
t.Fatalf("Failed to read data (missing), %v", err) | ||
} | ||
|
||
alt_geoms, err := AltGeometries(body) | ||
|
||
if err != nil { | ||
t.Fatalf("Expect data (valid) failed") | ||
} | ||
|
||
if len(alt_geoms) != 0 { | ||
t.Fatalf("Expect data (missing) to fail") | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.