X-Git-Url: https://ruderich.org/simon/gitweb/?p=safcm%2Fsafcm.git;a=blobdiff_plain;f=frontend%2Fchanges_test.go;fp=cmd%2Fsafcm%2Fsync_changes_test.go;h=02a95c40c24101d1250b9edb031fc98ea6399428;hp=219373c9522e4edfba458d3dd410b306c7ccdb06;hb=ecbcb0132728cc18016819a214378b642d92278e;hpb=b0f49e5d47786984e24731b200d3d3d7d6add263 diff --git a/cmd/safcm/sync_changes_test.go b/frontend/changes_test.go similarity index 96% rename from cmd/safcm/sync_changes_test.go rename to frontend/changes_test.go index 219373c..02a95c4 100644 --- a/cmd/safcm/sync_changes_test.go +++ b/frontend/changes_test.go @@ -13,14 +13,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -package main +package frontend import ( "io/fs" "testing" "ruderich.org/simon/safcm" - "ruderich.org/simon/safcm/cmd/safcm/config" "ruderich.org/simon/safcm/testutil" ) @@ -157,15 +156,13 @@ func TestFormatChanges(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - s := &Sync{ - config: &config.Config{ - DryRun: tc.dryRun, - Quiet: tc.quiet, - }, - isTTY: tc.isTTY, + c := Changes{ + DryRun: tc.dryRun, + Quiet: tc.quiet, + IsTTY: tc.isTTY, } - res := s.formatChanges(tc.resp) + res := c.FormatChanges(tc.resp) testutil.AssertEqual(t, "res", res, tc.exp) }) } @@ -656,14 +653,12 @@ func TestFormatFileChanges(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - s := &Sync{ - config: &config.Config{ - DryRun: tc.dryRun, - }, - isTTY: tc.isTTY, + c := Changes{ + DryRun: tc.dryRun, + IsTTY: tc.isTTY, } - res := s.formatFileChanges(tc.changes) + res := c.FormatFileChanges(tc.changes) testutil.AssertEqual(t, "res", res, tc.exp) }) } @@ -773,14 +768,12 @@ func TestFormatPackageChanges(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - s := &Sync{ - config: &config.Config{ - DryRun: tc.dryRun, - }, - isTTY: tc.isTTY, + c := Changes{ + DryRun: tc.dryRun, + IsTTY: tc.isTTY, } - res := s.formatPackageChanges(tc.changes) + res := c.FormatPackageChanges(tc.changes) testutil.AssertEqual(t, "res", res, tc.exp) }) } @@ -931,14 +924,12 @@ func TestFormatServiceChanges(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - s := &Sync{ - config: &config.Config{ - DryRun: tc.dryRun, - }, - isTTY: tc.isTTY, + c := Changes{ + DryRun: tc.dryRun, + IsTTY: tc.isTTY, } - res := s.formatServiceChanges(tc.changes) + res := c.FormatServiceChanges(tc.changes) testutil.AssertEqual(t, "res", res, tc.exp) }) } @@ -1230,15 +1221,13 @@ func TestFormatCommandChanges(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - s := &Sync{ - config: &config.Config{ - DryRun: tc.dryRun, - Quiet: tc.quiet, - }, - isTTY: tc.isTTY, + c := Changes{ + DryRun: tc.dryRun, + Quiet: tc.quiet, + IsTTY: tc.isTTY, } - res := s.formatCommandChanges(tc.changes) + res := c.FormatCommandChanges(tc.changes) testutil.AssertEqual(t, "res", res, tc.exp) }) }