forked from ublue-os/uupd
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing): add basic tests for most modules
- Loading branch information
1 parent
7bc4ebe
commit f592125
Showing
18 changed files
with
413 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package brew_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ublue-os/uupd/drv/brew" | ||
"github.com/ublue-os/uupd/drv/generic" | ||
appLogging "github.com/ublue-os/uupd/pkg/logging" | ||
) | ||
|
||
func InitBaseConfig() brew.BrewUpdater { | ||
var initConfiguration = generic.UpdaterInitConfiguration{ | ||
DryRun: false, | ||
Ci: false, | ||
Verbose: false, | ||
Environment: nil, | ||
Logger: appLogging.NewMuteLogger(), | ||
} | ||
driv, _ := brew.BrewUpdater{}.New(initConfiguration) | ||
return driv | ||
} | ||
|
||
func TestProperSteps(t *testing.T) { | ||
brewUpdater := InitBaseConfig() | ||
brewUpdater.Config.Enabled = false | ||
|
||
if brewUpdater.Steps() != 0 { | ||
t.Fatalf("Expected no steps when module is disabled") | ||
} | ||
|
||
brewUpdater.Config.Enabled = true | ||
if brewUpdater.Steps() == 0 { | ||
t.Fatalf("Expected steps to be added") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package distrobox_test | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"github.com/ublue-os/uupd/drv/distrobox" | ||
"github.com/ublue-os/uupd/drv/generic" | ||
appLogging "github.com/ublue-os/uupd/pkg/logging" | ||
"github.com/ublue-os/uupd/pkg/session" | ||
) | ||
|
||
func InitBaseConfig() distrobox.DistroboxUpdater { | ||
var initConfiguration = generic.UpdaterInitConfiguration{ | ||
DryRun: false, | ||
Ci: false, | ||
Verbose: false, | ||
Environment: nil, | ||
Logger: appLogging.NewMuteLogger(), | ||
} | ||
driv, _ := distrobox.DistroboxUpdater{}.New(initConfiguration) | ||
return driv | ||
} | ||
|
||
func TestProperSteps(t *testing.T) { | ||
updater := InitBaseConfig() | ||
updater.Config.Enabled = false | ||
|
||
if updater.Steps() != 0 { | ||
t.Fatalf("Expected no steps when module is disabled") | ||
} | ||
|
||
updater.Config.Enabled = true | ||
if updater.Steps() == 0 { | ||
t.Fatalf("Expected steps to be added") | ||
} | ||
} | ||
|
||
func TestProperUserSteps(t *testing.T) { | ||
updater := InitBaseConfig() | ||
|
||
mockUser := []session.User{ | ||
{UID: 0, Name: "root"}, | ||
{UID: 1, Name: "roote"}, | ||
{UID: 2, Name: "rooto"}, | ||
} | ||
updater.SetUsers(mockUser) | ||
|
||
if reported := updater.Steps(); reported != 1+len(mockUser) { | ||
log.Fatalf("Incorrect number of steps for users: %d", reported) | ||
} | ||
updater.Config.Enabled = false | ||
if reported := updater.Steps(); reported != 0 { | ||
log.Fatalf("Incorrect number of steps for users: %d", reported) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package flatpak_test | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"github.com/ublue-os/uupd/drv/flatpak" | ||
"github.com/ublue-os/uupd/drv/generic" | ||
appLogging "github.com/ublue-os/uupd/pkg/logging" | ||
"github.com/ublue-os/uupd/pkg/session" | ||
) | ||
|
||
func InitBaseConfig() flatpak.FlatpakUpdater { | ||
var initConfiguration = generic.UpdaterInitConfiguration{ | ||
DryRun: false, | ||
Ci: false, | ||
Verbose: false, | ||
Environment: nil, | ||
Logger: appLogging.NewMuteLogger(), | ||
} | ||
driv, _ := flatpak.FlatpakUpdater{}.New(initConfiguration) | ||
return driv | ||
} | ||
|
||
func TestProperSteps(t *testing.T) { | ||
updater := InitBaseConfig() | ||
updater.Config.Enabled = false | ||
|
||
if updater.Steps() != 0 { | ||
t.Fatalf("Expected no steps when module is disabled") | ||
} | ||
|
||
updater.Config.Enabled = true | ||
if updater.Steps() == 0 { | ||
t.Fatalf("Expected steps to be added") | ||
} | ||
} | ||
|
||
func TestProperUserSteps(t *testing.T) { | ||
updater := InitBaseConfig() | ||
|
||
mockUser := []session.User{ | ||
{UID: 0, Name: "root"}, | ||
{UID: 1, Name: "roote"}, | ||
{UID: 2, Name: "rooto"}, | ||
} | ||
updater.SetUsers(mockUser) | ||
|
||
if reported := updater.Steps(); reported != 1+len(mockUser) { | ||
log.Fatalf("Incorrect number of steps for users: %d", reported) | ||
} | ||
updater.Config.Enabled = false | ||
if reported := updater.Steps(); reported != 0 { | ||
log.Fatalf("Incorrect number of steps for users: %d", reported) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package rpmostree_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ublue-os/uupd/drv/generic" | ||
"github.com/ublue-os/uupd/drv/rpmostree" | ||
appLogging "github.com/ublue-os/uupd/pkg/logging" | ||
) | ||
|
||
func InitBaseConfig() rpmostree.RpmOstreeUpdater { | ||
var initConfiguration = generic.UpdaterInitConfiguration{ | ||
DryRun: false, | ||
Ci: false, | ||
Verbose: false, | ||
Environment: nil, | ||
Logger: appLogging.NewMuteLogger(), | ||
} | ||
driv, _ := rpmostree.RpmOstreeUpdater{}.New(initConfiguration) | ||
return driv | ||
} | ||
|
||
func TestProperSteps(t *testing.T) { | ||
rpmostreeUpdater := InitBaseConfig() | ||
rpmostreeUpdater.Config.Enabled = false | ||
|
||
if rpmostreeUpdater.Steps() != 0 { | ||
t.Fatalf("Expected no steps when module is disabled") | ||
} | ||
|
||
rpmostreeUpdater.Config.Enabled = true | ||
if rpmostreeUpdater.Steps() == 0 { | ||
t.Fatalf("Expected steps to be added") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.