mirror of
https://github.com/kopia/kopia.git
synced 2026-01-01 19:17:56 -05:00
* feat(cli): support for defining notification profiles via CLI
Profile management:
```
$ kopia notification profile configure email \
--profile-name=X \
--smtp-server=smtp.gmail.com \
--smtp-port=587 \
--smtp-username=X \
--smtp-password=X \
--mail-from=X \
--mail-to=X \
--format=html|txt \
[--send-test-notification]
$ kopia notification profile configure pushover --profile-name=X \
--user-key=X \
--app-token=X \
--format=html|txt \
[--send-test-notification]
$ kopia notification profile configure webhook --profile-name=X \
--endpooint=http://some-address:port/path \
--method=POST|PUT \
--format=html|txt \
[--send-test-notification]
$ kopia notification profile test --profile-name=X
$ kopia notification profile delete --profile-name=X
$ kopia notification profile list
```
Template management:
```
$ kopia notification template show X
$ kopia notification template set X \
--from-stdin | --from-file=X | --editor
$ kopia notification template remove X
$ kopia notification template list
```
Implements #1958
* additional refactoring for testability, various naming tweaks
30 lines
648 B
Go
30 lines
648 B
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/kopia/kopia/internal/repotesting"
|
|
)
|
|
|
|
func TestNotificationTemplatesAutocomplete(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var a notificationTemplateNameArg
|
|
|
|
ctx, env := repotesting.NewEnvironment(t, repotesting.FormatNotImportant)
|
|
|
|
require.Contains(t,
|
|
a.listNotificationTemplates(ctx, env.Repository),
|
|
"test-notification.txt")
|
|
|
|
a.templateName = "no-such-prefix"
|
|
require.Empty(t, a.listNotificationTemplates(ctx, env.Repository))
|
|
|
|
a.templateName = "test-notif"
|
|
require.Contains(t,
|
|
a.listNotificationTemplates(ctx, env.Repository),
|
|
"test-notification.txt")
|
|
}
|