Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

1010 B
Raw Blame
// SiYuan - https://github.com/siyuan-note/siyuan
// Copyright (c) 2020-present, b3log.org
// SPDX-License-Identifier: AGPL-3.0-or-later

package cmd

import (
	"testing"

	"github.com/siyuan-note/siyuan/kernel/conf"
	"github.com/siyuan-note/siyuan/kernel/model"
	"github.com/spf13/cobra"
)

func TestRepoAndSyncCommandsReportUnavailableOperations(t *testing.T) {
	previousConf, previousDryRun := model.Conf, dryRun
	model.Conf = &model.AppConf{Lang: "en", Repo: model.NewConfSection(conf.NewRepo()), Sync: model.NewConfSection(conf.NewSync())}
	model.Conf.Sync.Load().Enabled = false
	dryRun = false
	t.Cleanup(func() { model.Conf, dryRun = previousConf, previousDryRun })
	for _, command := range []*cobra.Command{repoCheckoutCmd, syncCmd, syncPushCmd, syncPullCmd} {
		t.Run(command.Name(), func(t *testing.T) {
			input := &cobra.Command{}
			input.Flags().String("id", "missing", "")
			if err := command.RunE(input, nil); err == nil {
				t.Fatal("unavailable operation reported success")
			}
		})
	}
}