]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - frontend/changes_test.go
safcm: move sync_changes.go and term.go to frontend package
[safcm/safcm.git] / frontend / changes_test.go
similarity index 96%
rename from cmd/safcm/sync_changes_test.go
rename to frontend/changes_test.go
index 219373c9522e4edfba458d3dd410b306c7ccdb06..02a95c40c24101d1250b9edb031fc98ea6399428 100644 (file)
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-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)
                })
        }