mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 09:50:08 +01:00
cbda064842
This commit contains the entire btcscript repository along with several changes needed to move all of the files into the txscript directory in order to prepare it for merging. This does NOT update btcd or any of the other packages to use the new location as that will be done separately. - All import paths in the old btcscript test files have been changed to the new location - All references to btcscript as the package name have been chagned to txscript This is ongoing work toward #214.
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
// Copyright (c) 2013-2015 Conformal Systems LLC.
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package txscript_test
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/btcsuite/btcd/txscript"
|
|
)
|
|
|
|
func TestSetLogWriter(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
w io.Writer
|
|
level string
|
|
expected error
|
|
}{
|
|
{
|
|
name: "nil writer",
|
|
w: nil,
|
|
level: "trace",
|
|
expected: errors.New("nil writer"),
|
|
},
|
|
{
|
|
name: "invalid log level",
|
|
w: os.Stdout,
|
|
level: "wrong",
|
|
expected: errors.New("invalid log level"),
|
|
},
|
|
{
|
|
name: "use off level",
|
|
w: os.Stdout,
|
|
level: "off",
|
|
expected: errors.New("min level can't be greater than max. Got min: 6, max: 5"),
|
|
},
|
|
{
|
|
name: "pass",
|
|
w: os.Stdout,
|
|
level: "debug",
|
|
expected: nil,
|
|
},
|
|
}
|
|
|
|
t.Logf("Running %d tests", len(tests))
|
|
for i, test := range tests {
|
|
err := txscript.SetLogWriter(test.w, test.level)
|
|
if err != nil {
|
|
if err.Error() != test.expected.Error() {
|
|
t.Errorf("SetLogWriter #%d (%s) wrong result\n"+
|
|
"got: %v\nwant: %v", i, test.name, err,
|
|
test.expected)
|
|
}
|
|
} else {
|
|
if test.expected != nil {
|
|
t.Errorf("SetLogWriter #%d (%s) wrong result\n"+
|
|
"got: %v\nwant: %v", i, test.name, err,
|
|
test.expected)
|
|
}
|
|
}
|
|
}
|
|
}
|