forked from XiaoMi/soar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cli test frame work bats (XiaoMi#181)
* import bats for cli test https://github.com/sstephenson/bats * add simple test case for cli use bats * format main.bats add env * replace main_test.sh with main.bats make explain suggestion sorted make index suggestion sorted * add test database world_x * update bats golden result * make docker add 180s timeout 1. add timeout for docker start 2. add not explain able sql test case into explain_test.go * explain info Using index VS Using index condition remove nonappearence key from explain extra info * add timeout for test
- Loading branch information
1 parent
c2a0544
commit 9df3418
Showing
18 changed files
with
4,866 additions
and
2,670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
bin/ | ||
release/ | ||
test/tmp/ | ||
common/version.go | ||
doc/blueprint/ | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2018 Xiaomi, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package common | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestCaptureOutput(t *testing.T) { | ||
c1 := make(chan string, 1) | ||
// test output buf large than 65535 | ||
length := 1<<16 + 1 | ||
go func() { | ||
str := captureOutput( | ||
func() { | ||
var str []string | ||
for i := 0; i < length; i++ { | ||
str = append(str, "a") | ||
} | ||
fmt.Println(strings.Join(str, "")) | ||
}, | ||
) | ||
c1 <- str | ||
}() | ||
|
||
select { | ||
case res := <-c1: | ||
if len(res) <= length { | ||
t.Errorf("want %d, got %d", length, len(res)) | ||
} | ||
case <-time.After(1 * time.Second): | ||
t.Error("capture timeout, pipe read hangup") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.