Best Ginkgo code snippet using types.Verbosity
config_test.go
Source:config_test.go
...36 repConf = types.ReporterConfig{TeamcityReport: "foo"}37 Ω(repConf.WillGenerateReport()).Should(BeTrue())38 })39 })40 Describe("Verbosity", func() {41 It("returns the appropriate verbosity level", func() {42 repConf := types.ReporterConfig{}43 Ω(repConf.Verbosity()).Should(Equal(types.VerbosityLevelNormal))44 repConf = types.ReporterConfig{Succinct: true}45 Ω(repConf.Verbosity()).Should(Equal(types.VerbosityLevelSuccinct))46 repConf = types.ReporterConfig{Verbose: true}47 Ω(repConf.Verbosity()).Should(Equal(types.VerbosityLevelVerbose))48 repConf = types.ReporterConfig{VeryVerbose: true}49 Ω(repConf.Verbosity()).Should(Equal(types.VerbosityLevelVeryVerbose))50 })51 It("can do verbosity math", func() {52 Ω(types.VerbosityLevelNormal.LT(types.VerbosityLevelVeryVerbose)).Should(BeTrue())53 Ω(types.VerbosityLevelNormal.LT(types.VerbosityLevelVerbose)).Should(BeTrue())54 Ω(types.VerbosityLevelNormal.LT(types.VerbosityLevelNormal)).Should(BeFalse())55 Ω(types.VerbosityLevelNormal.LT(types.VerbosityLevelSuccinct)).Should(BeFalse())56 Ω(types.VerbosityLevelNormal.LTE(types.VerbosityLevelVeryVerbose)).Should(BeTrue())57 Ω(types.VerbosityLevelNormal.LTE(types.VerbosityLevelVerbose)).Should(BeTrue())58 Ω(types.VerbosityLevelNormal.LTE(types.VerbosityLevelNormal)).Should(BeTrue())59 Ω(types.VerbosityLevelNormal.LTE(types.VerbosityLevelSuccinct)).Should(BeFalse())60 Ω(types.VerbosityLevelNormal.GT(types.VerbosityLevelVeryVerbose)).Should(BeFalse())61 Ω(types.VerbosityLevelNormal.GT(types.VerbosityLevelVerbose)).Should(BeFalse())62 Ω(types.VerbosityLevelNormal.GT(types.VerbosityLevelNormal)).Should(BeFalse())63 Ω(types.VerbosityLevelNormal.GT(types.VerbosityLevelSuccinct)).Should(BeTrue())64 Ω(types.VerbosityLevelNormal.GTE(types.VerbosityLevelVeryVerbose)).Should(BeFalse())65 Ω(types.VerbosityLevelNormal.GTE(types.VerbosityLevelVerbose)).Should(BeFalse())66 Ω(types.VerbosityLevelNormal.GTE(types.VerbosityLevelNormal)).Should(BeTrue())67 Ω(types.VerbosityLevelNormal.GTE(types.VerbosityLevelSuccinct)).Should(BeTrue())68 Ω(types.VerbosityLevelNormal.Is(types.VerbosityLevelVeryVerbose)).Should(BeFalse())69 Ω(types.VerbosityLevelNormal.Is(types.VerbosityLevelVerbose)).Should(BeFalse())70 Ω(types.VerbosityLevelNormal.Is(types.VerbosityLevelNormal)).Should(BeTrue())71 Ω(types.VerbosityLevelNormal.Is(types.VerbosityLevelSuccinct)).Should(BeFalse())72 })73 })74 })75 Describe("VetConfig", func() {76 var suiteConf types.SuiteConfig77 var repConf types.ReporterConfig78 var flagSet types.GinkgoFlagSet79 var goFlagSet *flag.FlagSet80 BeforeEach(func() {81 var err error82 goFlagSet = flag.NewFlagSet("test", flag.ContinueOnError)83 goFlagSet.Int("count", 1, "")84 goFlagSet.Int("parallel", 0, "")85 flagSet, err = types.NewAttachedGinkgoFlagSet(goFlagSet, types.GinkgoFlags{}, nil, types.GinkgoFlagSections{}, types.GinkgoFlagSection{})86 Ω(err).ShouldNot(HaveOccurred())87 suiteConf = types.NewDefaultSuiteConfig()88 repConf = types.NewDefaultReporterConfig()89 })90 Context("when all is well", func() {91 It("returns no errors", func() {92 errors := types.VetConfig(flagSet, suiteConf, repConf)93 Ω(errors).Should(BeEmpty())94 })95 })96 Context("when unsupported go flags are parsed", func() {97 BeforeEach(func() {98 goFlagSet.Parse([]string{"-count=2", "-parallel=2"})99 })100 It("returns errors when unsupported go flags are set", func() {101 errors := types.VetConfig(flagSet, suiteConf, repConf)102 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidGoFlagCount(), types.GinkgoErrors.InvalidGoFlagParallel()))103 })104 })105 Describe("errors related to parallelism", func() {106 Context("when parallel total is less than one", func() {107 BeforeEach(func() {108 suiteConf.ParallelTotal = 0109 })110 It("errors", func() {111 errors := types.VetConfig(flagSet, suiteConf, repConf)112 Ω(errors).Should(ContainElement(types.GinkgoErrors.InvalidParallelTotalConfiguration()))113 })114 })115 Context("when parallel node is less than one", func() {116 BeforeEach(func() {117 suiteConf.ParallelProcess = 0118 })119 It("errors", func() {120 errors := types.VetConfig(flagSet, suiteConf, repConf)121 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidParallelProcessConfiguration()))122 })123 })124 Context("when parallel node is greater than parallel total", func() {125 BeforeEach(func() {126 suiteConf.ParallelProcess = suiteConf.ParallelTotal + 1127 })128 It("errors", func() {129 errors := types.VetConfig(flagSet, suiteConf, repConf)130 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidParallelProcessConfiguration()))131 })132 })133 Context("when running in parallel", func() {134 var server *ghttp.Server135 BeforeEach(func() {136 server = ghttp.NewServer()137 server.SetAllowUnhandledRequests(true)138 server.SetUnhandledRequestStatusCode(http.StatusOK)139 suiteConf.ParallelTotal = 2140 suiteConf.ParallelHost = server.URL()141 })142 AfterEach(func() {143 server.Close()144 })145 Context("and parallel host is not set", func() {146 BeforeEach(func() {147 suiteConf.ParallelHost = ""148 })149 It("errors", func() {150 errors := types.VetConfig(flagSet, suiteConf, repConf)151 Ω(errors).Should(ConsistOf(types.GinkgoErrors.MissingParallelHostConfiguration()))152 })153 })154 Context("when trying to dry run in parallel", func() {155 BeforeEach(func() {156 suiteConf.DryRun = true157 })158 It("errors", func() {159 errors := types.VetConfig(flagSet, suiteConf, repConf)160 Ω(errors).Should(ConsistOf(types.GinkgoErrors.DryRunInParallelConfiguration()))161 })162 })163 })164 })165 Describe("file filter errors", func() {166 Context("with an invalid --focus-file and/or --skip-file", func() {167 BeforeEach(func() {168 suiteConf.FocusFiles = append(suiteConf.FocusFiles, "bloop:123a")169 suiteConf.SkipFiles = append(suiteConf.SkipFiles, "bloop:123b")170 })171 It("errors", func() {172 errors := types.VetConfig(flagSet, suiteConf, repConf)173 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidFileFilter("bloop:123a"), types.GinkgoErrors.InvalidFileFilter("bloop:123b")))174 })175 })176 })177 Describe("validating --output-interceptor-mode", func() {178 It("errors if an invalid output interceptor mode is specified", func() {179 suiteConf.OutputInterceptorMode = "DURP"180 errors := types.VetConfig(flagSet, suiteConf, repConf)181 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidOutputInterceptorModeConfiguration("DURP")))182 for _, value := range []string{"", "dup", "DUP", "swap", "SWAP", "none", "NONE"} {183 suiteConf.OutputInterceptorMode = value184 errors = types.VetConfig(flagSet, suiteConf, repConf)185 Ω(errors).Should(BeEmpty())186 }187 })188 })189 Context("when more than one verbosity flag is set", func() {190 It("errors", func() {191 repConf.Succinct, repConf.Verbose, repConf.VeryVerbose = true, true, false192 errors := types.VetConfig(flagSet, suiteConf, repConf)193 Ω(errors).Should(ConsistOf(types.GinkgoErrors.ConflictingVerbosityConfiguration()))194 repConf.Succinct, repConf.Verbose, repConf.VeryVerbose = true, false, true195 errors = types.VetConfig(flagSet, suiteConf, repConf)196 Ω(errors).Should(ConsistOf(types.GinkgoErrors.ConflictingVerbosityConfiguration()))197 repConf.Succinct, repConf.Verbose, repConf.VeryVerbose = false, true, true198 errors = types.VetConfig(flagSet, suiteConf, repConf)199 Ω(errors).Should(ConsistOf(types.GinkgoErrors.ConflictingVerbosityConfiguration()))200 repConf.Succinct, repConf.Verbose, repConf.VeryVerbose = true, true, true201 errors = types.VetConfig(flagSet, suiteConf, repConf)202 Ω(errors).Should(ConsistOf(types.GinkgoErrors.ConflictingVerbosityConfiguration()))203 })204 })205 })206})...
expand.go
Source:expand.go
1package expansion2import (3 "github.com/metamatex/metamate/asg/pkg/v0/asg/fieldnames"4 "github.com/metamatex/metamate/asg/pkg/v0/asg/graph"5 "github.com/metamatex/metamate/asg/pkg/v0/asg/graph/endpointflags"6 "github.com/metamatex/metamate/asg/pkg/v0/asg/graph/fieldflags"7 "github.com/metamatex/metamate/asg/pkg/v0/asg/graph/typeflags"8 "github.com/metamatex/metamate/asg/pkg/v0/asg/typenames"9 "log"10)11var String = graph.StringField12var Int = graph.Int32Field13var Float = graph.Float64Field14var Bool = graph.BoolField15var Enum = graph.EnumField16var Object = graph.TypeField17var List = graph.ListField18func Expand(verbosity int, root *graph.RootNode) (err error) {19 Step(verbosity, root, "add type meta", func() {20 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {21 tn.AddFieldNodes(22 graph.TypeField(fieldnames.Id, typenames.ServiceId),23 graph.ListField(graph.TypeField(fieldnames.AlternativeIds, typenames.Id)),24 graph.TypeField(fieldnames.CreatedAt, typenames.Timestamp),25 )26 tn.Flags().Set(typeflags.HasTypeMeta, true)27 })28 })29 paths := getFromToCardinalityPathNodes(root)30 Step(verbosity, root, "generate collections", func() {31 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {32 _, ok := paths[tn.Name()]33 if ok {34 generateCollection(root, tn)35 }36 })37 })38 Step(verbosity, root, "generate relations", func() {39 generateRelationNames(root, paths)40 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {41 _, ok := paths[tn.Name()]42 if ok {43 generateRelations(root, paths, tn)44 tn.AddFieldNodes(graph.TypeField(fieldnames.Relations, typenames.Relations(tn.Name()), graph.Flags{45 fieldflags.Filter: false,46 fieldflags.Sort: false,47 }))48 }49 })50 })51 Step(verbosity, root, "generate relationships", func() {52 generateRelationships(root, paths)53 })54 Step(verbosity, root, "determine is in list", func() {55 determineIsInListFlag(root)56 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {57 tn.Flags().Set(typeflags.IsInList, true)58 })59 })60 Step(verbosity, root, "generate list filters", func() {61 root.Types.Flagged(typeflags.IsInList, true).Each(func(tn *graph.TypeNode) {62 generateListFilter(root, tn)63 })64 })65 Step(verbosity, root, "generate sort types", func() {66 root.Types.Flagged(typeflags.IsEntity, true).Each(func(tn *graph.TypeNode) {67 generateTypeSort(root, tn)68 })69 })70 Step(verbosity, root, "add basic filter", func() {71 addBasicFilters(root)72 })73 Step(verbosity, root, "generate filter types", func() {74 root.Types.Flagged(typeflags.IsEntity, true).Each(func(tn *graph.TypeNode) {75 err := generateTypeFilter(root, tn)76 if err != nil {77 log.Fatal(err)78 }79 })80 })81 Step(verbosity, root, "generate select types", func() {82 root.Types.Flagged(typeflags.IsEntity, true).Each(func(tn *graph.TypeNode) {83 generateSelectRecursive(root, tn)84 })85 })86 Step(verbosity, root, "generate response types", func() {87 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {88 generateGetResponse(root, tn)89 })90 })91 Step(verbosity, root, "generate response select types", func() {92 root.Types.Flagged(typeflags.IsResponse, true).Each(func(tn *graph.TypeNode) {93 generateSelectRecursive(root, tn)94 })95 root.Types.ByNames(typenames.Pagination).Each(func(tn *graph.TypeNode) {96 generateSelectRecursive(root, tn)97 })98 })99 Step(verbosity, root, "generate request types", func() {100 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {101 _, ok := paths[tn.Name()]102 if ok {103 generateGetRelations(root, paths, tn)104 generateGetCollectionNode(root, tn)105 }106 generateGetRequest(root, tn)107 if ok {108 tn.Edges.Type.GetRequest().AddFieldNodes(graph.TypeField(fieldnames.Relations, typenames.GetRelations(tn.Name()), graph.Flags{109 fieldflags.Filter: false,110 }))111 tn.Edges.Type.GetCollection().AddFieldNodes(graph.TypeField(fieldnames.Relations, typenames.GetRelations(tn.Name()), graph.Flags{112 fieldflags.Filter: false,113 }))114 }115 })116 })117 Step(verbosity, root, "generate pipe contexts", func() {118 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {119 generatePipeGetContext(root, tn)120 generatePipeContext(root, tn)121 })122 })123 Step(verbosity, root, "generate pipe request types", func() {124 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {125 generatePipeRequest(root, tn)126 })127 })128 Step(verbosity, root, "generate pipe response types", func() {129 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {130 generatePipeResponse(root, tn)131 })132 })133 Step(verbosity, root, "generate request filter types", func() {134 root.Types.Flagged(typeflags.IsRequest, true).Each(func(tn *graph.TypeNode) {135 err := func() (err error) {136 err = generateFilterRecursive(root, tn)137 if err != nil {138 return139 }140 return141 }()142 if err != nil {143 log.Fatal(err)144 }145 })146 root.Types.ByNames(typenames.GetMode, typenames.RequestMeta).Each(func(tn *graph.TypeNode) {147 err := generateFilterRecursive(root, tn)148 if err != nil {149 log.Fatal(err)150 }151 })152 })153 Step(verbosity, root, "generate endpoints", func() {154 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {155 generateGetEndpoint(root, tn)156 generatePipeEndpoint(root, tn)157 })158 })159 Step(verbosity, root, "generate endpoint types", func() {160 root.Types.Flagged(typeflags.GetEndpoints, true).Each(func(tn *graph.TypeNode) {161 generateGetEndpointType(root, tn)162 generatePipeEndpointType(root, tn)163 })164 })165 Step(verbosity, root, "generate action endpoint types", func() {166 root.Endpoints.Flagged(endpointflags.IsActionEndpoint, true).Each(func(en *graph.EndpointNode) {167 generateActionEndpointType(root, en)168 })169 })170 Step(verbosity, root, "generate endpoint filter types", func() {171 root.Types.Flagged(typeflags.IsEndpoint, true).Each(func(tn *graph.TypeNode) {172 err := generateTypeFilter(root, tn)173 if err != nil {174 log.Fatal(err)175 }176 })177 })178 Step(verbosity, root, "add endpoint kind to requests", func() {179 //generateEndpointUnion(root)180 addEndpointKindToRequests(root)181 })182 Step(verbosity, root, "generate endpoints", func() {183 //generateEndpointUnion(root)184 generateEndpoints(root)185 })186 Step(verbosity, root, "generate endpoints filter", func() {187 err := generateTypeFilter(root, root.Types.MustByName(typenames.Endpoints))188 if err != nil {189 log.Fatal(err)190 }191 })192 Step(verbosity, root, "add endpoints field to service", func() {193 root.Types.MustByName(typenames.Service).AddFieldNodes(graph.TypeField(fieldnames.Endpoints, typenames.Endpoints))194 })195 Step(verbosity, root, "add endpoints filter field to service filter", func() {196 root.Types.MustByName(typenames.Filter(typenames.Service)).AddFieldNodes(graph.TypeField(fieldnames.Endpoints, typenames.Filter(typenames.Endpoints)))197 })198 Step(verbosity, root, "set scopes", func() {199 root.Endpoints.Each(func(en *graph.EndpointNode) {200 reqTn := en.Edges.Type.Request()201 reqTn.Flags().Set(typeflags.RequestScope, true)202 reqTn.Edges.Types.Dependencies().Each(func(tn *graph.TypeNode) {203 tn.Flags().Set(typeflags.RequestScope, true)204 })205 rspTn := en.Edges.Type.Response()206 rspTn.Flags().Set(typeflags.ResponseScope, true)207 rspTn.Edges.Types.Dependencies().Each(func(tn *graph.TypeNode) {208 tn.Flags().Set(typeflags.ResponseScope, true)209 })210 })211 })212 return213}214func determineIsInListFlag(root *graph.RootNode) {215 root.216 Fields.217 Each(func(fn *graph.FieldNode) {218 if fn.Flags().Is(fieldflags.IsList, true) {219 if fn.Edges.Type.Resolver.Holds() != "" {220 fn.Edges.Type.Holds().Flags().Set(typeflags.IsInList, true)221 }222 }223 })224}...
args.go
Source:args.go
...11 "github.com/agrski/greg/pkg/types"12 "github.com/mattn/go-isatty"13 "golang.org/x/oauth2"14)15type VerbosityLevel int16const (17 VerbosityQuiet VerbosityLevel = iota18 VerbosityNormal19 VerbosityHigh20)21const (22 httpScheme = "https"23 githubHost = "github.com"24)25var supportedHosts = [...]fetchTypes.HostName{githubHost}26type rawArgs struct {27 // Application behaviour28 host string29 org string30 repo string31 url string32 filetypes string33 searchPattern string34 accessToken string35 accessTokenFile string36 caseInsensitive bool37 // Presentation/display behaviour38 quiet bool39 verbose bool40 colour bool41 noColour bool42}43type Args struct {44 location fetchTypes.Location45 searchPattern string46 filetypes []types.FileExtension47 tokenSource oauth2.TokenSource48 caseInsensitive bool49 verbosity VerbosityLevel50 enableColour bool51}52func GetArgs() (*Args, error) {53 raw, err := parseArguments()54 if err != nil {55 return nil, err56 }57 err = isSupportedHost(raw.host)58 if err != nil {59 return nil, err60 }61 location, err := getLocation(raw)62 if err != nil {63 return nil, err64 }65 pattern, err := getSearchPattern(raw.searchPattern)66 if err != nil {67 return nil, err68 }69 tokenSource, err := getAccessToken(raw.accessToken, raw.accessTokenFile)70 if err != nil {71 return nil, err72 }73 filetypes := getFiletypes(raw.filetypes)74 verbosity := getVerbosity(raw.quiet, raw.verbose)75 enableColour := getColourEnabled(raw.colour, raw.noColour)76 return &Args{77 location: location,78 searchPattern: pattern,79 filetypes: filetypes,80 tokenSource: tokenSource,81 caseInsensitive: raw.caseInsensitive,82 verbosity: verbosity,83 enableColour: enableColour,84 }, nil85}86func parseArguments() (*rawArgs, error) {87 args := rawArgs{}88 flag.StringVar(&args.host, "host", githubHost, "git hostname, default: github.com")89 flag.StringVar(&args.org, "org", "", "organisation name, e.g. agrski")90 flag.StringVar(&args.repo, "repo", "", "repository name, e.g. gitfind")91 flag.StringVar(92 &args.url,93 "url",94 "",95 "Full URL of git repository, e.g https://github.com/agrski/gitfind",96 )97 flag.StringVar(&args.filetypes, "type", "", "filetype suffix, e.g. md or go")98 flag.StringVar(&args.accessToken, "access-token", "", "raw access token for repository access")99 flag.StringVar(100 &args.accessTokenFile,101 "access-token-file",102 "",103 "file containing access token for repository access",104 )105 flag.BoolVar(&args.caseInsensitive, "i", false, "enable case-insensitive matching")106 flag.BoolVar(&args.quiet, "quiet", false, "disable logging; overrides verbose mode")107 flag.BoolVar(&args.verbose, "verbose", false, "increase logging; overridden by quiet mode")108 flag.BoolVar(&args.colour, "colour", false, "force coloured outputs; overridden by no-colour")109 flag.BoolVar(&args.noColour, "no-colour", false, "force uncoloured outputs; overrides colour")110 flag.Parse()111 if 1 != flag.NArg() {112 return nil, fmt.Errorf("expected one search term but found %d", flag.NArg())113 }114 args.searchPattern = flag.Arg(0)115 return &args, nil116}117func getLocation(args *rawArgs) (fetchTypes.Location, error) {118 if isEmpty(args.url) && (isEmpty(args.org) || isEmpty(args.repo)) {119 return fetchTypes.Location{}, errors.New("must specify either url or both org and repo")120 }121 if !isEmpty(args.url) && (!isEmpty(args.org) || !isEmpty(args.repo)) {122 return fetchTypes.Location{}, errors.New("cannot specify both url and org or repo")123 }124 if isEmpty(args.url) {125 return fetchTypes.Location{126 Host: fetchTypes.HostName(args.host),127 Organisation: fetchTypes.OrganisationName(args.org),128 Repository: fetchTypes.RepositoryName(args.repo),129 }, nil130 }131 return parseLocationFromURL(args.url)132}133func parseLocationFromURL(rawURL string) (fetchTypes.Location, error) {134 if isEmpty(rawURL) {135 return fetchTypes.Location{}, errors.New("cannot parse empty string")136 }137 noWhitespace := strings.TrimSpace(rawURL)138 parts := strings.SplitAfter(noWhitespace, "://")139 if len(parts) > 2 {140 return fetchTypes.Location{}, fmt.Errorf("cannot parse malformed string '%v'", noWhitespace)141 }142 withoutScheme := parts[len(parts)-1]143 hostAndPath := strings.Split(withoutScheme, "/")144 if len(hostAndPath) < 3 {145 return fetchTypes.Location{}, fmt.Errorf("unable to parse host, org, and repo from %v", hostAndPath)146 }147 host := hostAndPath[0]148 org := hostAndPath[1]149 repo := hostAndPath[2]150 repo = strings.TrimSuffix(repo, ".git")151 if isEmpty(host) {152 return fetchTypes.Location{}, errors.New("host cannot be empty")153 }154 if isEmpty(org) {155 return fetchTypes.Location{}, errors.New("org cannot be empty")156 }157 if isEmpty(repo) {158 return fetchTypes.Location{}, errors.New("repo cannot be empty")159 }160 return fetchTypes.Location{161 Host: fetchTypes.HostName(host),162 Organisation: fetchTypes.OrganisationName(org),163 Repository: fetchTypes.RepositoryName(repo),164 }, nil165}166func getFiletypes(filetypes string) []types.FileExtension {167 if isEmpty(filetypes) {168 return nil169 }170 suffixes := strings.Split(filetypes, ",")171 extensions := make([]types.FileExtension, len(suffixes))172 for idx, s := range suffixes {173 normalised := match.NormaliseExtension(types.FileExtension(s))174 extensions[idx] = normalised175 }176 return extensions177}178func getSearchPattern(pattern string) (string, error) {179 if isEmpty(pattern) {180 return "", errors.New("search term must be specified; wrap multiple words in quotes")181 }182 return pattern, nil183}184func isEmpty(s string) bool {185 return "" == strings.TrimSpace(s)186}187func isSupportedHost(host string) error {188 hostname := fetchTypes.HostName(host)189 for _, h := range supportedHosts {190 if hostname == h {191 return nil192 }193 }194 return fmt.Errorf("unsupported git hosting provider %s", host)195}196func getAccessToken(197 accessToken string,198 accessTokenFile string,199) (oauth2.TokenSource, error) {200 if isEmpty(accessToken) && isEmpty(accessTokenFile) {201 return nil, errors.New("must specify either access token or access token file")202 }203 if !isEmpty(accessToken) && !isEmpty(accessTokenFile) {204 return nil, errors.New("only one of access token and access token file may be specified")205 }206 tokenSource, err := auth.TokenSourceFromString(accessToken)207 if err != nil {208 tokenSource, err = auth.TokenSourceFromFile(accessTokenFile)209 }210 return tokenSource, err211}212func getVerbosity(quiet bool, verbose bool) VerbosityLevel {213 if quiet {214 return VerbosityQuiet215 } else if verbose {216 return VerbosityHigh217 } else {218 return VerbosityNormal219 }220}221func getColourEnabled(forceColour bool, forceNoColour bool) bool {222 if forceNoColour {223 return false224 } else if forceColour {225 return true226 } else {227 fd := os.Stdout.Fd()228 return isatty.IsTerminal(fd) || isatty.IsCygwinTerminal(fd)229 }230}...
Verbosity
Using AI Code Generation
1import (2func main() {3 fmt.Println(beego.BConfig.RunMode)4 fmt.Println(beego.BConfig.CopyRequestBody)5 fmt.Println(beego.BConfig.CopyRequestBody)6 beego.BeeLogger.DelLogger("console")7 beego.BeeLogger.DelLogger("file")8 beego.BeeLogger.SetLogger("console", `{"level":7}`)9 beego.BeeLogger.SetLogger("file", `{"filename":"test.log"}`)10 beego.BeeLogger.EnableFuncCallDepth(true)11 beego.BeeLogger.SetLogFuncCallDepth(3)12 beego.BeeLogger.Debug("this is a test")13 beego.BeeLogger.Info("this is a test")14 beego.BeeLogger.Notice("this is a test")15 beego.BeeLogger.Warn("this is a test")16 beego.BeeLogger.Error("this is a test")17 beego.BeeLogger.Critical("this is a test")18 beego.BeeLogger.Alert("this is a test")19 beego.BeeLogger.Emergency("this is a test")20 beego.BeeLogger.Log(7, "this is a test")21 beego.BeeLogger.Async()22 beego.BeeLogger.Flush()23 beego.BeeLogger.Close()24 beego.BeeLogger.Close()25}26import (27func main() {28 fmt.Println(beego.BConfig.RunMode)29 fmt.Println(beego.BConfig.CopyRequestBody)30 fmt.Println(beego.BConfig.CopyRequestBody)31 beego.BeeLogger.DelLogger("console")32 beego.BeeLogger.DelLogger("file")33 beego.BeeLogger.SetLogger("console", `{"level":7}`)34 beego.BeeLogger.SetLogger("file", `{"filename":"test.log"}`)35 beego.BeeLogger.EnableFuncCallDepth(true)36 beego.BeeLogger.SetLogFuncCallDepth(3)37 beego.BeeLogger.Debug("this is a test")38 beego.BeeLogger.Info("
Verbosity
Using AI Code Generation
1import (2func main() {3 glog.V(2).Info("This is a test")4 glog.V(1).Info("This is a test")5 glog.V(0).Info("This is a test")6}7import (8func main() {9 glog.V(2).Info("This is a test")10 glog.V(1).Info("This is a test")11 glog.V(0).Info("This is a test")12}13import (14func main() {15 glog.V(2).Info("This is a test")16 glog.V(1).Info("This is a test")17 glog.V(0).Info("This is a test")18}19import (20func main() {21 glog.V(2).Info("This is a test")22 glog.V(1).Info("This is a test")23 glog.V(0).Info("This is a test")24}25import (26func main() {27 glog.V(2).Info("This is a test")28 glog.V(1).Info("This is a test")29 glog.V(0).Info("This is a test")30}31import (32func main() {33 glog.V(2).Info("This is a test")34 glog.V(1).Info("This is a test")35 glog.V(0).Info("This is a test")36}
Verbosity
Using AI Code Generation
1import "fmt"2import "types"3func main() {4 fmt.Println(types.Verbosity)5}6import "testing"7func TestVerbosity(t *testing.T) {8 if Verbosity != 1 {9 t.Error("Verbosity is not 1")10 }11}12import "fmt"13import "types"14func main() {15 fmt.Println(types.Verbosity)16}17import "testing"18func TestVerbosity(t *testing.T) {19 if Verbosity != 1 {20 t.Error("Verbosity is not 1")21 }22}23--- FAIL: TestVerbosity (0.00s)24import "testing"25func TestVerbosity(t *testing.T) {26 if Verbosity != 1 {27 t.Error("Verbosity is not 1")28 }29}
Verbosity
Using AI Code Generation
1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println(types.Verbosity(1))5}6const (7func (v Verbosity) String() string {8 switch v {9 }10}11import (12func TestVerbosity(t *testing.T) {13 assert.Equal(t, VerbosityNone.String(), "none")14 assert.Equal(t, VerbosityNormal.String(), "normal")15 assert.Equal(t, VerbosityHigh.String(), "high")16}17The Verbosity type is defined in the types package. When you import the types package, the Verbosity type is available to the main package. The main package imports the types package and uses the
Verbosity
Using AI Code Generation
1import (2func main() {3}4import (5func main() {6}7import (8func main() {9}10import (11func main() {12}13import (14func main() {15}16import (17func main() {18}19import (20func main() {21}22import (23func main() {24}25import (26func main() {27}28import (29func main() {30}31import (32func main() {33}34import (35func main() {36}37import (38func main() {39}40import (41func main() {42}43import (44func main() {45}46import (47func main() {48}49import (
Verbosity
Using AI Code Generation
1import (2func main() {3 fmt.Printf("%# v", pretty.Formatter(1))4}5import (6func main() {7 err := errors.New("error message")8 fmt.Printf("%w", err)9}10import (11func main() {12 err := errors.New("error message")13 fmt.Printf("%s", err)14}15import (16func main() {17 fmt.Printf("%v", 1)18}19import (20func main() {21 fmt.Printf("%v", true)22}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!