Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions log/colorstring/colorstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
// ColorFunc ...
type ColorFunc func(a ...interface{}) string

func addColor(color Color, msg string) string {
func AddColor(color Color, msg string) string {
return string(color) + msg + string(resetColor)
}

Expand All @@ -34,37 +34,37 @@ func NoColor(a ...interface{}) string {

// Black ...
func Black(a ...interface{}) string {
return addColor(blackColor, fmt.Sprint(a...))
return AddColor(blackColor, fmt.Sprint(a...))
}

// Red ...
func Red(a ...interface{}) string {
return addColor(redColor, fmt.Sprint(a...))
return AddColor(redColor, fmt.Sprint(a...))
}

// Green ...
func Green(a ...interface{}) string {
return addColor(greenColor, fmt.Sprint(a...))
return AddColor(greenColor, fmt.Sprint(a...))
}

// Yellow ...
func Yellow(a ...interface{}) string {
return addColor(yellowColor, fmt.Sprint(a...))
return AddColor(yellowColor, fmt.Sprint(a...))
}

// Blue ...
func Blue(a ...interface{}) string {
return addColor(blueColor, fmt.Sprint(a...))
return AddColor(blueColor, fmt.Sprint(a...))
}

// Magenta ...
func Magenta(a ...interface{}) string {
return addColor(magentaColor, fmt.Sprint(a...))
return AddColor(magentaColor, fmt.Sprint(a...))
}

// Cyan ...
func Cyan(a ...interface{}) string {
return addColor(cyanColor, fmt.Sprint(a...))
return AddColor(cyanColor, fmt.Sprint(a...))
}

// ColorfFunc ...
Expand Down
50 changes: 49 additions & 1 deletion log/colorstring/colorstring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package colorstring

import (
"fmt"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -16,7 +17,7 @@ func TestAddColor(t *testing.T) {
t.Log("colored_string = color + string + reset_color")
{
desiredColored := "\x1b[30;1m" + "test" + "\x1b[0m"
colored := addColor(blackColor, "test")
colored := AddColor(blackColor, "test")
require.Equal(t, desiredColored, colored)
}
}
Expand Down Expand Up @@ -52,3 +53,50 @@ func TestBlackf(t *testing.T) {
require.Equal(t, desiredColored, colored)
}
}

func TestGitError(t *testing.T) {
fmt.Printf(`
Error:
fetch failed:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Intan90002/empty.git/'
`)

fmt.Println(strings.Repeat("-", 80))
fmt.Printf(`
%s:
fetch failed:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: %s
`,
Red("Error"),
Redf("Authentication failed for '%s'", Cyan("https://github.com/Intan90002/empty.git/")),
)
}

func TestXcodeError(t *testing.T) {
fmt.Printf(`
Command failed with exit status 70 (xcodebuild "-exportArchive" "-archivePath" "./code-sign-test.xcarchive" "-exportPath" "./exported" "-exportOptionsPlist" "./export_options.plist"):
error: exportArchive: "share-extension.appex" requires a provisioning profile.
error: exportArchive: "code-sign-test.app" requires a provisioning profile.
error: exportArchive: "watchkit-app.app" requires a provisioning profile.
error: exportArchive: "watchkit-app Extension.appex" requires a provisioning profile.
`)

fmt.Println(strings.Repeat("-", 80))
fmt.Printf(`
Command failed with exit status 70 (%s):
error: exportArchive: %s
error: exportArchive: %s
error: exportArchive: %s
error: exportArchive: %s
`,
Cyan(`xcodebuild "-exportArchive" "-archivePath" "./code-sign-test.xcarchive" "-exportPath" "./exported" "-exportOptionsPlist" "./export_options.plist"`),
Red(`"share-extension.appex" requires a provisioning profile.`),
Red(`"code-sign-test.app" requires a provisioning profile.`),
Red(`"watchkit-app.app" requires a provisioning profile.`),
Red(`"watchkit-app Extension.appex" requires a provisioning profile.`),
)
}