Skip to content

Commit

Permalink
Merge pull request #292 from weaveworks/test-refactoring
Browse files Browse the repository at this point in the history
Test refactoring
  • Loading branch information
peterbourgon committed Jun 29, 2015
2 parents f8be412 + 90a0286 commit 56701b6
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 121 deletions.
28 changes: 28 additions & 0 deletions bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ function spell_check {
return $lint_result
}

function test_mismatch {
filename="$1"
package=$(grep '^package ' $filename | awk '{print $2}')
local lint_result=0

if [[ $package == "main" ]]; then
continue # in package main, all bets are off
fi

if [[ $filename == *"_internal_test.go" ]]; then
if [[ $package == *"_test" ]]; then
lint_result=1
echo "${filename}: should not be part of a _test package"
fi
else
if [[ ! $package == *"_test" ]]; then
lint_result=1
echo "${filename}: should be part of a _test package"
fi
fi

return $lint_result
}

function lint_go {
filename="$1"
local lint_result=0
Expand Down Expand Up @@ -81,6 +105,10 @@ function lint {
;;
esac

if [[ $filename == *"_test.go" ]]; then
test_mismatch "${filename}" || lint_result=1
fi

spell_check "${filename}" || lint_result=1

return $lint_result
Expand Down
2 changes: 1 addition & 1 deletion experimental/_integration/easy_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package integration
package integration_test

import (
"encoding/json"
Expand Down
21 changes: 0 additions & 21 deletions report/diff_test.go

This file was deleted.

15 changes: 7 additions & 8 deletions report/merge.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package report

// Merge() functions for all topology datatypes.
// The general semantics are that the receiver is modified, and what's merged
// in isn't.
// Merge functions for all topology datatypes. The general semantics are that
// the receiver is modified, and what's merged in isn't.

// Merge merges another Report into the receiver.
func (r *Report) Merge(other Report) {
Expand Down Expand Up @@ -38,9 +37,9 @@ func (m *NodeMetadatas) Merge(other NodeMetadatas) {
}
}

// Merge merges another EdgeMetadatas into the receiver.
// If other is from another probe this is the union of both metadatas. Keys
// present in both are summed.
// Merge merges another EdgeMetadatas into the receiver. If other is from
// another probe this is the union of both metadatas. Keys present in both are
// summed.
func (e *EdgeMetadatas) Merge(other EdgeMetadatas) {
for id, edgemeta := range other {
local := (*e)[id]
Expand All @@ -65,8 +64,8 @@ func (m *EdgeMetadata) Merge(other EdgeMetadata) {
}
}

// Flatten sums two EdgeMetadatas, their 'Window's should be the same size. The
// two EdgeMetadatas should represent different edges at the same time.
// Flatten sums two EdgeMetadatas. Their windows should be the same duration;
// they should represent different edges at the same time.
func (m *EdgeMetadata) Flatten(other EdgeMetadata) {
if other.WithBytes {
m.WithBytes = true
Expand Down
Loading

0 comments on commit 56701b6

Please sign in to comment.