1 Star 0 Fork 49

Chalin/apidoc

forked from caixw/apidoc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config_test.go 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
caixw 提交于 2017-12-31 10:54 . 修正 input/encoding 包错误
// Copyright 2016 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package main
import (
"strings"
"testing"
"github.com/issue9/assert"
"github.com/caixw/apidoc/input"
"github.com/caixw/apidoc/output"
"github.com/caixw/apidoc/types"
)
func TestConfig_sanitize(t *testing.T) {
a := assert.New(t)
conf := &config{}
err := conf.sanitize()
a.Error(err)
a.Equal(err.(*types.OptionsError).Field, "version")
// 版本号错误
conf.Version = "4.0"
err = conf.sanitize()
a.Error(err)
a.Equal(err.(*types.OptionsError).Field, "version")
// 未声明 inputs
conf.Version = "4.0.1"
err = conf.sanitize()
a.Error(err)
a.Equal(err.(*types.OptionsError).Field, "inputs")
// 未声明 output
conf.Inputs = []*input.Options{{}}
err = conf.sanitize()
a.Error(err)
a.Equal(err.(*types.OptionsError).Field, "output")
// 查看错误提示格式是否正确
conf.Output = &output.Options{}
conf.Inputs = append(conf.Inputs, &input.Options{
Lang: "123",
})
err = conf.sanitize()
a.Error(err)
a.True(strings.HasPrefix(err.(*types.OptionsError).Field, "inputs[0]"))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/chaalin/apidoc.git
git@gitee.com:chaalin/apidoc.git
chaalin
apidoc
apidoc
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385