Skip to content
Open
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
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Purpose

Brief description of the purpose of this change.

## Solution

High level overview of what was done. This is the roadmap for those who are going to CR.

## Semantic Versioning (check one)

- [ ] The following were changed in a non-backward compatible way and requires a major version bump:
- _[link to the breaking change in the diff]_
- [ ] Something public was added or changed in backward compatible way, this requires a minor version bump
- [ ] No public changes nor new features (backwards-compatible refactor or bug fix), so this can be included in a patch
release

## How to QA

- [ ] run the following related examples: **(fill in)**
- [ ] Other necessary steps needed to fully exercise the solution should be added here. **(fill in)**
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: sunday
commit-message:
prefix: fix
prefix-development: chore
include: scope
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.test
test-reports/
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is a Golang library; it doesn't produce
# any artifacts.
FROM scratch
33 changes: 9 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
PACKAGES = $(shell go list ./... | grep -v '/vendor/')
SHELL := /bin/bash

default: test
test: tools
rm -rf test-reports
mkdir test-reports
go clean -testcache
GO111MODULE="off" go test -v 2>&1 ./... | go-junit-report -iocopy -set-exit-code -out test-reports/unit-test-report.xml

test-all: vet lint test test-race

test:
go test -v -parallel=4 ${PACKAGES}

test-race:
go test -v -race ${PACKAGES}

vet:
go vet ${PACKAGES}

lint:
@go get github.com/golang/lint/golint
go list ./... | grep -v vendor | xargs -n1 golint

cover:
@go get golang.org/x/tools/cmd/cover
go test -coverprofile=cover.out
go tool cover -html cover.out
rm cover.out

.PHONY: test test-race vet lint cover
tools:
go install github.com/jstemmer/go-junit-report/[email protected]
GO111MODULE="off" go get golang.org/x/crypto/ssh/terminal
1 change: 1 addition & 0 deletions aviary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: 1
4 changes: 2 additions & 2 deletions read.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func (i *UI) read(opts *readOptions) (string, error) {
resultErr = fmt.Errorf("failed to read the input: %s", err)
}

resultStr = strings.TrimSuffix(line, LineSep)
resultStr = strings.Trim(line, LineSep)
// brute force for the moment
resultStr = strings.TrimSuffix(line, "\n")
resultStr = strings.TrimSuffix(resultStr, "\n")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I'm not sure of the reasoning for this line so I left it in, but I'm guessing you needed it to get rid of new lines no matter what since they probably weren't working for windows. Using Trim instead of TrimSuffix should solve this problem, so you may be able to remove this line

}
}()

Expand Down
14 changes: 10 additions & 4 deletions read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ package input

import (
"bytes"
"fmt"
"io"
"io/ioutil"
"testing"
)

func TestRead(t *testing.T) {
var stringWithSpace = fmt.Sprintf("taichi nakashima%s", LineSep)
var expectedWithSpace = "taichi nakashima"
var stringNoSpace = fmt.Sprintf("passw0rd%s", LineSep)
var expectedNoSpace = "passw0rd"

cases := []struct {
opts *readOptions
userInput io.Reader
Expand All @@ -18,17 +24,17 @@ func TestRead(t *testing.T) {
mask: false,
maskVal: "",
},
userInput: bytes.NewBufferString("passw0rd"),
expect: "passw0rd",
userInput: bytes.NewBufferString(stringNoSpace),
expect: expectedNoSpace,
},

{
opts: &readOptions{
mask: false,
maskVal: "",
},
userInput: bytes.NewBufferString("taichi nakashima"),
expect: "taichi nakashima",
userInput: bytes.NewBufferString(stringWithSpace),
expect: expectedWithSpace,
},

// No good way to test masking...
Expand Down
22 changes: 22 additions & 0 deletions skynet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Testing with Skynet - https://github.com/Workiva/skynet/tree/master/docs
name: unit-tests
image: golang:1.18-bullseye
description: run unit tests
size: small
timeout: 600 # 10 minutes
contact: support-onecloud

run:
on-pull-request: true
on-tag: true
when-branch-name-is:
- master

scripts:
- make test

artifacts:
- test-reports

test-reports:
- test-reports