Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
package common
import (
"testing"
"fiskerinc.com/modules/utils/elptr"
)
func TestRemoveParsedS19HexFiles(t *testing.T) {
var exampleECU UpdateManifestECU = UpdateManifestECU{
Files: []*UpdateManifestFile{
{
Parsed: nil,
},
{
Parsed:elptr.ElPtr(false),
},
{
Parsed:elptr.ElPtr(true),
},
{
Parsed: nil,
},
{
Parsed:elptr.ElPtr(true),
},
{
Parsed:elptr.ElPtr(false),
},
},
}
exampleECU.RemoveParsedS19HexFiles()
nonS19Count := 0
parsedS19Count := 0
originalS19Count := 0
for _, y := range exampleECU.Files{
if y.Parsed == nil{
nonS19Count += 1
}else{
if *y.Parsed{
parsedS19Count += 1
}else{
originalS19Count += 1
}
}
}
if nonS19Count != 2 {
t.Logf("Expected %d nons19, got %d\n", 2, nonS19Count)
t.Fail()
}
if parsedS19Count != 0 {
t.Logf("Expected %d parsed s19, got %d\n", 0, parsedS19Count)
t.Fail()
}
if originalS19Count != 2 {
t.Logf("Expected %d original s19, got %d\n", 2, originalS19Count)
t.Fail()
}
}
func TestRemoveOriginalS19HexFiles(t *testing.T) {
var exampleECU UpdateManifestECU = UpdateManifestECU{
Files: []*UpdateManifestFile{
{
Parsed: nil,
},
{
Parsed:elptr.ElPtr(false),
},
{
Parsed:elptr.ElPtr(true),
},
{
Parsed: nil,
},
{
Parsed:elptr.ElPtr(true),
},
{
Parsed:elptr.ElPtr(false),
},
},
}
exampleECU.RemoveOriginalS19HexFiles()
nonS19Count := 0
parsedS19Count := 0
originalS19Count := 0
for _, y := range exampleECU.Files{
if y.Parsed == nil{
nonS19Count += 1
}else{
if *y.Parsed{
parsedS19Count += 1
}else{
originalS19Count += 1
}
}
}
if nonS19Count != 2 {
t.Logf("Expected %d nons19, got %d\n", 2, nonS19Count)
t.Fail()
}
if parsedS19Count != 2 {
t.Logf("Expected %d parsed s19, got %d\n", 2, parsedS19Count)
t.Fail()
}
if originalS19Count != 0 {
t.Logf("Expected %d original s19, got %d\n", 0, originalS19Count)
t.Fail()
}
}