Files
Charon/backend/internal/caddy/importer_test.go
T
Wikid82 2eab570d54 Add comprehensive tests for services and middleware
- Implement tests for AuthMiddleware to handle cookie and token authentication.
- Create tests for the Importer and Manager in the Caddy package.
- Enhance AuthService tests with password change and token validation scenarios.
- Introduce tests for CertificateService to validate certificate listing and expiry.
- Expand LogService tests to cover log querying and pagination.
- Add NotificationService tests for creating, listing, and marking notifications as read.
- Implement ProxyHostService tests for CRUD operations and unique domain validation.
- Create RemoteServerService tests for CRUD operations.
- Add UpdateService tests to mock GitHub API responses for version checking.
- Introduce UptimeService tests to check host availability and notifications for down hosts.
2025-11-20 20:14:35 -05:00

25 lines
608 B
Go

package caddy
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewImporter(t *testing.T) {
importer := NewImporter("/usr/bin/caddy")
assert.NotNil(t, importer)
assert.Equal(t, "/usr/bin/caddy", importer.caddyBinaryPath)
importerDefault := NewImporter("")
assert.NotNil(t, importerDefault)
assert.Equal(t, "caddy", importerDefault.caddyBinaryPath)
}
func TestImporter_ParseCaddyfile_NotFound(t *testing.T) {
importer := NewImporter("caddy")
_, err := importer.ParseCaddyfile("non-existent-file")
assert.Error(t, err)
assert.Contains(t, err.Error(), "caddyfile not found")
}