cli/cmd/updater/service_examples_test.go
Charon c340303314 refactor: flatten commands, extract php/ci to own repos (#2)
## Summary
- Extract PHP/Laravel commands to `core/php` repo (42 files, standalone module)
- Extract CI/release + SDK commands to `core/ci` repo (10 files)
- Remove `internal/variants/` build tag system entirely
- Move all 30 remaining command packages from `internal/cmd/` to top-level `cmd/`
- Rewrite `main.go` with direct imports — no more variant selection
- PHP and CI are now optional via commented import lines in main.go

Co-authored-by: Claude <developers@lethean.io>
Reviewed-on: #2
Co-authored-by: Charon <charon@lthn.ai>
Co-committed-by: Charon <charon@lthn.ai>
2026-02-16 14:45:06 +00:00

42 lines
1.1 KiB
Go

package updater_test
import (
"fmt"
"log"
"forge.lthn.ai/core/cli/cmd/updater"
)
func ExampleNewUpdateService() {
// Mock the update check functions to prevent actual updates during tests
updater.CheckForUpdates = func(owner, repo, channel string, forceSemVerPrefix bool, releaseURLFormat string) error {
fmt.Println("CheckForUpdates called")
return nil
}
defer func() {
updater.CheckForUpdates = nil // Restore original function
}()
config := updater.UpdateServiceConfig{
RepoURL: "https://github.com/owner/repo",
Channel: "stable",
CheckOnStartup: updater.CheckAndUpdateOnStartup,
}
updateService, err := updater.NewUpdateService(config)
if err != nil {
log.Fatalf("Failed to create update service: %v", err)
}
if err := updateService.Start(); err != nil {
log.Printf("Update check failed: %v", err)
}
// Output: CheckForUpdates called
}
func ExampleParseRepoURL() {
owner, repo, err := updater.ParseRepoURL("https://github.com/owner/repo")
if err != nil {
log.Fatalf("Failed to parse repo URL: %v", err)
}
fmt.Printf("Owner: %s, Repo: %s", owner, repo)
// Output: Owner: owner, Repo: repo
}