fix: save config after removerepo and LC_ALL=C for info command #54
							
								
								
									
										1
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Makefile
									
									
									
									
									
								
							| @@ -73,5 +73,6 @@ test-coverage: | ||||
| 	bash scripts/coverage-badge.sh | ||||
|  | ||||
| e2e-test: clean build | ||||
| 	rm -f ./e2e-tests/alr | ||||
| 	cp alr e2e-tests | ||||
| 	go test -tags=e2e ./... | ||||
| @@ -19,33 +19,52 @@ | ||||
| package e2etests_test | ||||
|  | ||||
| import ( | ||||
| 	"regexp" | ||||
| 	"bytes" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/efficientgo/e2e" | ||||
| 	expect "github.com/tailscale/goexpect" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
|  | ||||
| func TestE2EAlrAddRepo(t *testing.T) { | ||||
| 	dockerMultipleRun( | ||||
| 		t, | ||||
| 		"add-repo", | ||||
| 		"add-repo-remove-repo", | ||||
| 		COMMON_SYSTEMS, | ||||
| 		func(t *testing.T, r e2e.Runnable) { | ||||
| 			runTestCommands(t, r, time.Second*10, []expect.Batcher{ | ||||
| 				&expect.BSnd{S: "alr addrepo --name alr-repo --url https://gitea.plemya-x.ru/Plemya-x/alr-repo.git ; echo ALR-ADD-REPO-RETURN-CODE $?\n"}, | ||||
| 				&expect.BCas{C: []expect.Caser{ | ||||
| 					&expect.Case{ | ||||
| 						R: regexp.MustCompile(`ALR-ADD-REPO-RETURN-CODE 0\n$`), | ||||
| 						T: expect.OK(), | ||||
| 					}, | ||||
| 					&expect.Case{ | ||||
| 						R: regexp.MustCompile(`ALR-ADD-REPO-RETURN-CODE \d\n$`), | ||||
| 						T: expect.Fail(expect.NewStatus(expect.Internal, "Unexpected return code!")), | ||||
| 					}, | ||||
| 				}}, | ||||
| 			}) | ||||
| 			err := r.Exec(e2e.NewCommand( | ||||
| 				"alr", | ||||
| 				"addrepo", | ||||
| 				"--name", | ||||
| 				"alr-repo", | ||||
| 				"--url", | ||||
| 				"https://gitea.plemya-x.ru/Plemya-x/alr-repo.git", | ||||
| 			)) | ||||
| 			assert.NoError(t, err) | ||||
|  | ||||
| 			err = r.Exec(e2e.NewCommand( | ||||
| 				"bash", | ||||
| 				"-c", | ||||
| 				"cat $HOME/.config/alr/alr.toml", | ||||
| 			)) | ||||
| 			assert.NoError(t, err) | ||||
|  | ||||
| 			err = r.Exec(e2e.NewCommand( | ||||
| 				"alr", | ||||
| 				"removerepo", | ||||
| 				"--name", | ||||
| 				"alr-repo", | ||||
| 			)) | ||||
| 			assert.NoError(t, err) | ||||
|  | ||||
| 			var buf bytes.Buffer | ||||
| 			err = r.Exec(e2e.NewCommand( | ||||
| 				"bash", | ||||
| 				"-c", | ||||
| 				"cat $HOME/.config/alr/alr.toml", | ||||
| 			), e2e.WithExecOptionStdout(&buf)) | ||||
| 			assert.NoError(t, err) | ||||
| 			assert.Contains(t, buf.String(), "rootCmd") | ||||
| 		}, | ||||
| 	) | ||||
| } | ||||
|   | ||||
							
								
								
									
										52
									
								
								e2e-tests/issue_53_lc_all_c_info_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								e2e-tests/issue_53_lc_all_c_info_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| // ALR - Any Linux Repository | ||||
| // Copyright (C) 2025 Евгений Храмов | ||||
| // | ||||
| // This program is free software: you can redistribute it and/or modify | ||||
| // it under the terms of the GNU General Public License as published by | ||||
| // the Free Software Foundation, either version 3 of the License, or | ||||
| // (at your option) any later version. | ||||
| // | ||||
| // This program is distributed in the hope that it will be useful, | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| // GNU General Public License for more details. | ||||
| // | ||||
| // You should have received a copy of the GNU General Public License | ||||
| // along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  | ||||
| //go:build e2e | ||||
|  | ||||
| package e2etests_test | ||||
|  | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/alecthomas/assert/v2" | ||||
| 	"github.com/efficientgo/e2e" | ||||
| ) | ||||
|  | ||||
| func TestE2EIssue53LcAllCInfo(t *testing.T) { | ||||
| 	dockerMultipleRun( | ||||
| 		t, | ||||
| 		"issue-53-lc-all-c-info", | ||||
| 		COMMON_SYSTEMS, | ||||
| 		func(t *testing.T, r e2e.Runnable) { | ||||
| 			err := r.Exec(e2e.NewCommand( | ||||
| 				"alr", | ||||
| 				"addrepo", | ||||
| 				"--name", | ||||
| 				"alr-repo", | ||||
| 				"--url", | ||||
| 				"https://gitea.plemya-x.ru/Plemya-x/alr-repo.git", | ||||
| 			)) | ||||
| 			assert.NoError(t, err) | ||||
|  | ||||
| 			err = r.Exec(e2e.NewCommand( | ||||
| 				"bash", | ||||
| 				"-c", | ||||
| 				"LANG=C alr info alr-bin", | ||||
| 			)) | ||||
| 			assert.NoError(t, err) | ||||
| 		}, | ||||
| 	) | ||||
| } | ||||
							
								
								
									
										3
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								go.mod
									
									
									
									
									
								
							| @@ -8,6 +8,7 @@ require ( | ||||
| 	gitea.plemya-x.ru/Plemya-x/fakeroot v0.0.1 | ||||
| 	github.com/AlecAivazis/survey/v2 v2.3.7 | ||||
| 	github.com/PuerkitoBio/purell v1.2.0 | ||||
| 	github.com/alecthomas/assert/v2 v2.2.1 | ||||
| 	github.com/alecthomas/chroma/v2 v2.9.1 | ||||
| 	github.com/charmbracelet/bubbles v0.20.0 | ||||
| 	github.com/charmbracelet/bubbletea v1.2.4 | ||||
| @@ -48,6 +49,7 @@ require ( | ||||
| 	github.com/Masterminds/sprig/v3 v3.2.3 // indirect | ||||
| 	github.com/Microsoft/go-winio v0.6.1 // indirect | ||||
| 	github.com/ProtonMail/go-crypto v1.0.0 // indirect | ||||
| 	github.com/alecthomas/repr v0.2.0 // indirect | ||||
| 	github.com/andybalholm/brotli v1.0.4 // indirect | ||||
| 	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect | ||||
| 	github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb // indirect | ||||
| @@ -81,6 +83,7 @@ require ( | ||||
| 	github.com/goreleaser/fileglob v1.3.0 // indirect | ||||
| 	github.com/hashicorp/errwrap v1.0.0 // indirect | ||||
| 	github.com/hashicorp/go-multierror v1.1.1 // indirect | ||||
| 	github.com/hexops/gotextdiff v1.0.3 // indirect | ||||
| 	github.com/huandu/xstrings v1.3.3 // indirect | ||||
| 	github.com/imdario/mergo v0.3.16 // indirect | ||||
| 	github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect | ||||
|   | ||||
							
								
								
									
										3
									
								
								info.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								info.go
									
									
									
									
									
								
							| @@ -122,6 +122,9 @@ func InfoCmd() *cli.Command { | ||||
| 				slog.Error("Can't detect system language", "err", err) | ||||
| 				os.Exit(1) | ||||
| 			} | ||||
| 			if systemLang == "" { | ||||
| 				systemLang = "en" | ||||
| 			} | ||||
|  | ||||
| 			if !all { | ||||
| 				info, err := distro.ParseOSRelease(ctx) | ||||
|   | ||||
| @@ -138,15 +138,15 @@ msgstr "" | ||||
| msgid "Error finding packages" | ||||
| msgstr "" | ||||
|  | ||||
| #: info.go:129 | ||||
| #: info.go:132 | ||||
| msgid "Error parsing os-release file" | ||||
| msgstr "" | ||||
|  | ||||
| #: info.go:138 | ||||
| #: info.go:141 | ||||
| msgid "Error resolving overrides" | ||||
| msgstr "" | ||||
|  | ||||
| #: info.go:147 info.go:153 | ||||
| #: info.go:150 info.go:156 | ||||
| msgid "Error encoding script variables" | ||||
| msgstr "" | ||||
|  | ||||
| @@ -477,7 +477,7 @@ msgstr "" | ||||
| msgid "Error opening config file" | ||||
| msgstr "" | ||||
|  | ||||
| #: repo.go:88 repo.go:153 | ||||
| #: repo.go:88 repo.go:153 repo.go:165 | ||||
| msgid "Error encoding config" | ||||
| msgstr "" | ||||
|  | ||||
| @@ -497,11 +497,11 @@ msgstr "" | ||||
| msgid "Error removing repo directory" | ||||
| msgstr "" | ||||
|  | ||||
| #: repo.go:170 | ||||
| #: repo.go:176 | ||||
| msgid "Error removing packages from database" | ||||
| msgstr "" | ||||
|  | ||||
| #: repo.go:182 | ||||
| #: repo.go:188 | ||||
| msgid "Pull all repositories that have changed" | ||||
| msgstr "" | ||||
|  | ||||
|   | ||||
| @@ -145,15 +145,15 @@ msgstr "Для команды info ожидался хотя бы 1 аргуме | ||||
| msgid "Error finding packages" | ||||
| msgstr "Ошибка при поиске пакетов" | ||||
|  | ||||
| #: info.go:129 | ||||
| #: info.go:132 | ||||
| msgid "Error parsing os-release file" | ||||
| msgstr "Ошибка при разборе файла выпуска операционной системы" | ||||
|  | ||||
| #: info.go:138 | ||||
| #: info.go:141 | ||||
| msgid "Error resolving overrides" | ||||
| msgstr "Ошибка устранения переорпеделений" | ||||
|  | ||||
| #: info.go:147 info.go:153 | ||||
| #: info.go:150 info.go:156 | ||||
| msgid "Error encoding script variables" | ||||
| msgstr "Ошибка кодирования переменных скрита" | ||||
|  | ||||
| @@ -497,7 +497,7 @@ msgstr "URL-адрес нового репозитория" | ||||
| msgid "Error opening config file" | ||||
| msgstr "Ошибка при открытии конфигурационного файла" | ||||
|  | ||||
| #: repo.go:88 repo.go:153 | ||||
| #: repo.go:88 repo.go:153 repo.go:165 | ||||
| msgid "Error encoding config" | ||||
| msgstr "Ошибка при кодировании конфигурации" | ||||
|  | ||||
| @@ -517,11 +517,11 @@ msgstr "Репозитория не существует" | ||||
| msgid "Error removing repo directory" | ||||
| msgstr "Ошибка при удалении каталога репозитория" | ||||
|  | ||||
| #: repo.go:170 | ||||
| #: repo.go:176 | ||||
| msgid "Error removing packages from database" | ||||
| msgstr "Ошибка при удалении пакетов из базы данных" | ||||
|  | ||||
| #: repo.go:182 | ||||
| #: repo.go:188 | ||||
| msgid "Pull all repositories that have changed" | ||||
| msgstr "Скачать все изменённые репозитории" | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user