当前位置: 首页>>代码示例>>Golang>>正文


Golang parsecli.NewHarness函数代码示例

本文整理汇总了Golang中github.com/ParsePlatform/parse-cli/parsecli.NewHarness函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHarness函数的具体用法?Golang NewHarness怎么用?Golang NewHarness使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewHarness函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestReadTriggerParams

func TestReadTriggerParams(t *testing.T) {
	t.Parallel()

	h := parsecli.NewHarness(t)
	defer h.Stop()

	h.Env.In = ioutil.NopCloser(strings.NewReader("\n"))
	_, err := readTriggerName(h.Env, nil)
	ensure.Err(t, err, regexp.MustCompile("Class name cannot be empty"))

	h.Env.In = ioutil.NopCloser(strings.NewReader("foo\n"))
	_, err = readTriggerName(h.Env, nil)
	ensure.Err(t, err, regexp.MustCompile("Trigger name cannot be empty"))

	h.Env.In = ioutil.NopCloser(strings.NewReader("foo\nbeforeSave"))
	hook, err := readTriggerName(h.Env, nil)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, *hook, triggerHook{ClassName: "foo", TriggerName: "beforeSave"})

	h.Env.In = ioutil.NopCloser(strings.NewReader("foo\nbeforeSave\napi.example.com/foo/beforeSave\n"))
	hook, err = readTriggerParams(h.Env, nil)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, *hook, triggerHook{
		ClassName:   "foo",
		TriggerName: "beforeSave",
		URL:         "https://api.example.com/foo/beforeSave",
	})
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:28,代码来源:triggers_test.go

示例2: TestShouldCreateNewApp

func TestShouldCreateNewApp(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()

	n := &newCmd{}

	h.Env.In = ioutil.NopCloser(strings.NewReader("new"))
	decision, err := n.promptCreateNewApp(h.Env, false)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, decision, "new")

	h.Env.In = ioutil.NopCloser(strings.NewReader("existing"))
	decision, err = n.promptCreateNewApp(h.Env, false)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, decision, "existing")

	h.Env.In = ioutil.NopCloser(strings.NewReader("other"))
	_, err = n.promptCreateNewApp(h.Env, false)
	ensure.Err(t, err, regexp.MustCompile("are the only valid options"))

	decision, err = n.promptCreateNewApp(h.Env, true)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, decision, "existing")

	n.createNewApp = true
	decision, err = n.promptCreateNewApp(h.Env, true)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, decision, "new")
}
开发者ID:z7z8th,项目名称:parse-cli,代码行数:30,代码来源:new_test.go

示例3: TestSetupAndConfigure

func TestSetupAndConfigure(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	h.MakeEmptyRoot()
	defer h.Stop()

	n := &newCmd{}
	h.Env.Type = parsecli.ParseFormat
	h.Env.In = ioutil.NopCloser(strings.NewReader("\n"))
	code, err := n.setupSample(h.Env, "myapp", &parsecli.ParseAppConfig{ApplicationID: "a"}, true, false)
	ensure.Nil(t, err)
	ensure.True(t, code)

	type jsSDKVersion struct {
		JS []string `json:"js"`
	}
	ht := parsecli.TransportFunc(func(r *http.Request) (*http.Response, error) {
		ensure.DeepEqual(t, r.URL.Path, "/1/jsVersions")
		rows := jsSDKVersion{JS: []string{"1.5.0", "1.6.0"}}
		return &http.Response{
			StatusCode: http.StatusOK,
			Body:       ioutil.NopCloser(strings.NewReader(jsonStr(t, rows))),
		}, nil
	})
	h.Env.ParseAPIClient = &parsecli.ParseAPIClient{APIClient: &parse.Client{Transport: ht}}
	err = n.configureSample(
		&addCmd{MakeDefault: true},
		"yolo",
		(&parsecli.ParseAppConfig{ApplicationID: "a"}).WithInternalMasterKey("m"),
		nil,
		h.Env,
	)
	ensure.Nil(t, err)
}
开发者ID:z7z8th,项目名称:parse-cli,代码行数:34,代码来源:new_test.go

示例4: TestMakeNewRelease

func TestMakeNewRelease(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()

	var d deployCmd
	info := deployInfo{
		ReleaseName:  "v2",
		ParseVersion: "latest",
		Checksums: deployFileData{
			Cloud:  map[string]string{"main.js": "4ece160cc8e5e828ee718e7367cf5d37"},
			Public: map[string]string{"index.html": "9e2354a0ebac5852bc674026137c8612"},
		},
		Versions: deployFileData{
			Cloud:  map[string]string{"main.js": "f2"},
			Public: map[string]string{"index.html": "f2"},
		},
	}
	ht := parsecli.TransportFunc(func(r *http.Request) (*http.Response, error) {
		ensure.DeepEqual(t, r.URL.Path, "/1/deploy")
		return &http.Response{
			StatusCode: http.StatusOK,
			Body:       ioutil.NopCloser(strings.NewReader(jsonStr(t, &info))),
		}, nil
	})
	h.Env.ParseAPIClient = &parsecli.ParseAPIClient{APIClient: &parse.Client{Transport: ht}}
	res, err := d.makeNewRelease(&deployInfo{}, h.Env)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, info, res)
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:30,代码来源:deploy_test.go

示例5: TestGetPrevDeplInfo

func TestGetPrevDeplInfo(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()

	var d deployCmd
	info := &deployInfo{
		ReleaseName:  "v1",
		ParseVersion: "latest",
		Checksums: deployFileData{
			Cloud:  map[string]string{"main.js": "d41d8cd98f00b204e9800998ecf8427e"},
			Public: map[string]string{"index.html": "d41d8cd98f00b204e9800998ecf8427e"},
		},
		Versions: deployFileData{
			Cloud:  map[string]string{"main.js": "f1"},
			Public: map[string]string{"index.html": "f1"},
		},
	}
	ht := parsecli.TransportFunc(func(r *http.Request) (*http.Response, error) {
		ensure.DeepEqual(t, r.URL.Path, "/1/deploy")
		return &http.Response{
			StatusCode: http.StatusOK,
			Body:       ioutil.NopCloser(strings.NewReader(jsonStr(t, info))),
		}, nil
	})
	h.Env.ParseAPIClient = &parsecli.ParseAPIClient{APIClient: &parse.Client{Transport: ht}}
	res, err := d.getPrevDeplInfo(h.Env)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, res, info)
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:30,代码来源:deploy_test.go

示例6: TestGenericGetSourceFiles

func TestGenericGetSourceFiles(t *testing.T) {
	t.Parallel()

	h := parsecli.NewHarness(t)
	h.MakeEmptyRoot()
	defer h.Stop()

	ensure.Nil(t, os.Mkdir(filepath.Join(h.Env.Root, "src"), 0755))
	for _, name := range []string{"index.html"} {
		file, err := os.Create(filepath.Join(h.Env.Root, "src", name))
		ensure.Nil(t, err)
		ensure.Nil(t, file.Close())
	}

	ensure.Nil(t, os.Symlink(filepath.Join(h.Env.Root, "src"), filepath.Join(h.Env.Root, "public")))

	var d deployCmd

	files, ignored, err := d.getSourceFiles(
		filepath.Join(h.Env.Root, "public"),
		map[string]struct{}{".html": {}},
		h.Env,
	)

	ensure.Nil(t, err)
	ensure.DeepEqual(t, files, []string{filepath.Join(h.Env.Root, "public", "index.html")})
	ensure.DeepEqual(t, len(ignored), 0)
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:28,代码来源:deploy_test.go

示例7: TestLatestVersion

func TestLatestVersion(t *testing.T) {
	t.Parallel()

	h := parsecli.NewHarness(t)
	defer h.Stop()

	ht := parsecli.TransportFunc(func(r *http.Request) (*http.Response, error) {
		ensure.DeepEqual(t, r.URL.Path, "/1/supported")
		return &http.Response{
			StatusCode: http.StatusOK,
			Body: ioutil.NopCloser(
				jsonpipe.Encode(
					map[string]string{"version": "2.0.2"},
				),
			),
		}, nil
	})
	h.Env.ParseAPIClient = &parsecli.ParseAPIClient{APIClient: &parse.Client{Transport: ht}}
	u := new(updateCmd)

	latestVersion, err := u.latestVersion(h.Env)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, latestVersion, "2.0.2")

	downloadURL, err := u.getDownloadURL(h.Env)
	ensure.StringContains(t,
		downloadURL, "https://github.com/ParsePlatform/parse-cli/releases/download/release_2.0.2")
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:28,代码来源:update_test.go

示例8: TestProjectType

func TestProjectType(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()

	h.MakeEmptyRoot()
	ensure.Nil(t, parsecli.CloneSampleCloudCode(h.Env, false))

	c := &configureCmd{}
	err := c.projectType(h.Env, []string{"1", "2"})
	ensure.Err(t, err, regexp.MustCompile("only an optional project type argument is expected"))

	h.Env.In = ioutil.NopCloser(strings.NewReader("invalid\n"))
	err = c.projectType(h.Env, nil)
	ensure.StringContains(t, h.Err.String(), "Invalid selection. Please enter a number")
	ensure.Err(t, err, regexp.MustCompile("Could not make a selection. Please try again."))
	h.Err.Reset()
	h.Out.Reset()

	h.Env.In = ioutil.NopCloser(strings.NewReader("0\n"))
	err = c.projectType(h.Env, nil)
	ensure.StringContains(t, h.Err.String(), "Please enter a number between 1 and")
	ensure.Err(t, err, regexp.MustCompile("Could not make a selection. Please try again."))
	h.Err.Reset()
	h.Out.Reset()

	h.Env.In = ioutil.NopCloser(strings.NewReader("1\n"))
	err = c.projectType(h.Env, nil)
	ensure.StringContains(t, h.Out.String(), "Successfully set project type to: parse")
	ensure.Nil(t, err)
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:31,代码来源:configure_test.go

示例9: TestLogInvalidLevel

func TestLogInvalidLevel(t *testing.T) {
	t.Parallel()
	l := logsCmd{}
	h := parsecli.NewHarness(t)
	defer h.Stop()
	err := l.run(h.Env, nil)
	ensure.Err(t, err, regexp.MustCompile(`invalid level: ""`))
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:8,代码来源:logs_test.go

示例10: TestFindAAPT

func TestFindAAPT(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()

	aapts := findAAPT("Resources")
	ensure.DeepEqual(t, aapts[:], []string{filepath.Join("Resources", "build_tools", "aapt")})
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:8,代码来源:android_symbol_uploader_test.go

示例11: TestPrintListOneAppNoDefaultKey

func TestPrintListOneAppNoDefaultKey(t *testing.T) {
	t.Parallel()
	conf := &parsecli.ParseConfig{Applications: map[string]*parsecli.ParseAppConfig{"first": {}}}
	h := parsecli.NewHarness(t)
	defer h.Stop()
	conf.PrettyPrintApps(h.Env)
	ensure.DeepEqual(t, h.Out.String(), "The following apps are associated with Cloud Code in the current directory:\n  first\n")
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:8,代码来源:list_test.go

示例12: TestRunSymbolsCmd

func TestRunSymbolsCmd(t *testing.T) {
	t.Parallel()

	h := parsecli.NewHarness(t)
	defer h.Stop()

	s := &symbolsCmd{}
	ensure.Err(t, s.run(h.Env, nil), regexp.MustCompile("Please specify path"))
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:9,代码来源:symbols_test.go

示例13: TestVersion

func TestVersion(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()
	var c versionCmd
	err := c.run(h.Env)
	ensure.Nil(t, err)
	ensure.DeepEqual(t, h.Out.String(), parsecli.Version+"\n")
	ensure.DeepEqual(t, h.Err.String(), "")
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:10,代码来源:version_test.go

示例14: TestBase64MD5OfFileNoFile

func TestBase64MD5OfFileNoFile(t *testing.T) {
	t.Parallel()
	h := parsecli.NewHarness(t)
	defer h.Stop()

	h.MakeEmptyRoot()
	testFile := filepath.Join(h.Env.Root, "test")
	_, err := base64MD5OfFile(testFile)
	ensure.NotNil(t, err)
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:10,代码来源:parse_symbol_uploader_test.go

示例15: TestUpgradeLegacyNoOp

func TestUpgradeLegacyNoOp(t *testing.T) {
	t.Parallel()

	h := parsecli.NewHarness(t)
	defer h.Stop()

	var m migrateCmd
	c := &parsecli.ParseConfig{ProjectConfig: &parsecli.ProjectConfig{Type: parsecli.ParseFormat}}
	_, err := m.upgradeLegacy(h.Env, c)
	ensure.Err(t, err, regexp.MustCompile("Already using the preferred config format."))
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:11,代码来源:migrate_test.go


注:本文中的github.com/ParsePlatform/parse-cli/parsecli.NewHarness函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。