Move logic to check if deviceinfo file exists to pkgs/deviceinfo (MR 37)

This is mostly a preparatory commit to later be able to read the
deviceinfo from multiple places. It has a bit better encapsulation,
and makes the functions methods, so that they can update deviceinfo
file in-place.
This commit is contained in:
Pablo Correa Gómez
2023-05-29 23:06:31 +02:00
committed by Clayton Craft
parent b2cdfe9da4
commit c87b926a53
3 changed files with 21 additions and 22 deletions

View File

@@ -58,7 +58,7 @@ func TestUnmarshal(t *testing.T) {
var d DeviceInfo
for _, table := range tables {
testName := fmt.Sprintf("unmarshal::'%s':", strings.ReplaceAll(table.in, "\n", "\\n"))
if err := unmarshal(strings.NewReader(table.in), &d); err != nil {
if err := d.unmarshal(strings.NewReader(table.in)); err != nil {
t.Errorf("%s received an unexpected err: ", err)
}