Compare commits

...

2 Commits

Author SHA1 Message Date
Igor Gov
ca897dd3c7 Update issue templates (#189) 2021-08-09 18:36:56 +03:00
RoyUP9
4406919565 added test workflow, added test for contains func (#184) 2021-08-09 16:04:00 +03:00
6 changed files with 148 additions and 0 deletions

38
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run mizu <command> '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Logs**
Upload logs:
1. Run the mizu command with `--set dump-logs=true` (e.g `mizu tap --set dump-logs=true`)
2. Try to reproduce the issue
3. CNTRL+C on terminal tab which runs mizu
4. Upload the logs zip file from ~/.mizu/mizu_logs_**.zip
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome]
**Additional context**
Add any other context about the problem here.

22
.github/workflows/test.yaml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: test
on:
pull_request:
branches:
- 'develop'
- 'main'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Test
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2

View File

@@ -65,3 +65,5 @@ clean-cli: ## Clean CLI.
clean-docker:
@(echo "DOCKER cleanup - NOT IMPLEMENTED YET " )
test: ## Run tests.
@echo "running cli tests"; cd cli && $(MAKE) test

View File

@@ -1,4 +1,5 @@
![Mizu: The API Traffic Viewer for Kubernetes](assets/mizu-logo.svg)
# The API Traffic Viewer for Kubernetes
A simple-yet-powerful API traffic viewer for Kubernetes to help you troubleshoot and debug your microservices. Think TCPDump and Chrome Dev Tools combined.

View File

@@ -39,3 +39,6 @@ build-all: ## Build for all supported platforms.
clean: ## Clean all build artifacts.
go clean
rm -rf ./bin/*
test: ## Run cli tests.
@go test ./... -race -coverprofile=coverage.out -covermode=atomic

View File

@@ -0,0 +1,82 @@
package mizu_test
import (
"github.com/up9inc/mizu/cli/mizu"
"testing"
)
func TestContainsExists(t *testing.T) {
tests := []struct {
slice []string
containsValue string
expected bool
}{
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "apple", expected: true},
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "orange", expected: true},
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "banana", expected: true},
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "grapes", expected: true},
}
for _, test := range tests {
actual := mizu.Contains(test.slice, test.containsValue)
if actual != test.expected {
t.Errorf("unexpected result - expected: %v, actual: %v", test.expected, actual)
}
}
}
func TestContainsNotExists(t *testing.T) {
tests := []struct {
slice []string
containsValue string
expected bool
}{
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "cat", expected: false},
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "dog", expected: false},
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "apples", expected: false},
{slice: []string{"apple", "orange", "banana", "grapes"}, containsValue: "rapes", expected: false},
}
for _, test := range tests {
actual := mizu.Contains(test.slice, test.containsValue)
if actual != test.expected {
t.Errorf("unexpected result - expected: %v, actual: %v", test.expected, actual)
}
}
}
func TestContainsEmptySlice(t *testing.T) {
tests := []struct {
slice []string
containsValue string
expected bool
}{
{slice: []string{}, containsValue: "cat", expected: false},
{slice: []string{}, containsValue: "dog", expected: false},
}
for _, test := range tests {
actual := mizu.Contains(test.slice, test.containsValue)
if actual != test.expected {
t.Errorf("unexpected result - expected: %v, actual: %v", test.expected, actual)
}
}
}
func TestContainsNilSlice(t *testing.T) {
tests := []struct {
slice []string
containsValue string
expected bool
}{
{slice: nil, containsValue: "cat", expected: false},
{slice: nil, containsValue: "dog", expected: false},
}
for _, test := range tests {
actual := mizu.Contains(test.slice, test.containsValue)
if actual != test.expected {
t.Errorf("unexpected result - expected: %v, actual: %v", test.expected, actual)
}
}
}