mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
rename /src to /internal (sorry i'll fix the prs)
This commit is contained in:
45
internal/ghupdate/ghupdate_test.go
Normal file
45
internal/ghupdate/ghupdate_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package ghupdate
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReleaseFindAssetBySuffix(t *testing.T) {
|
||||
r := release{
|
||||
Assets: []*releaseAsset{
|
||||
{Name: "test1.zip", Id: 1},
|
||||
{Name: "test2.zip", Id: 2},
|
||||
{Name: "test22.zip", Id: 22},
|
||||
{Name: "test3.zip", Id: 3},
|
||||
},
|
||||
}
|
||||
|
||||
asset, err := r.findAssetBySuffix("2.zip")
|
||||
if err != nil {
|
||||
t.Fatalf("Expected nil, got err: %v", err)
|
||||
}
|
||||
|
||||
if asset.Id != 2 {
|
||||
t.Fatalf("Expected asset with id %d, got %v", 2, asset)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractFailure(t *testing.T) {
|
||||
testDir := t.TempDir()
|
||||
|
||||
// Test with missing zip file
|
||||
missingZipPath := filepath.Join(testDir, "missing_test.zip")
|
||||
extractedPath := filepath.Join(testDir, "zip_extract")
|
||||
|
||||
if err := extract(missingZipPath, extractedPath); err == nil {
|
||||
t.Fatal("Expected Extract to fail due to missing zip file")
|
||||
}
|
||||
|
||||
// Test with missing tar.gz file
|
||||
missingTarPath := filepath.Join(testDir, "missing_test.tar.gz")
|
||||
|
||||
if err := extract(missingTarPath, extractedPath); err == nil {
|
||||
t.Fatal("Expected Extract to fail due to missing tar.gz file")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user