-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
152 additions
and
13 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
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,15 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/farseer-go/fs/asyncLocal" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestAsyncLocal(t *testing.T) { | ||
al := asyncLocal.New[string]() | ||
al.Set("A") | ||
assert.Equal(t, "A", al.Get()) | ||
al.Remove() | ||
assert.Equal(t, "", al.Get()) | ||
} |
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,2 @@ | ||
Test: | ||
Name: "test" |
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,75 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/farseer-go/fs" | ||
"github.com/farseer-go/fs/container" | ||
"github.com/farseer-go/fs/modules" | ||
"github.com/farseer-go/fs/trace" | ||
"github.com/farseer-go/fs/trace/eumCallType" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestTrace(t *testing.T) { | ||
fs.Initialize[modules.FarseerKernelModule]("unit test") | ||
|
||
assert.Equal(t, "Grpc", eumCallType.Grpc.ToString()) | ||
assert.Equal(t, "Http", eumCallType.Http.ToString()) | ||
assert.Equal(t, "Database", eumCallType.Database.ToString()) | ||
assert.Equal(t, "Redis", eumCallType.Redis.ToString()) | ||
assert.Equal(t, "Mq", eumCallType.Mq.ToString()) | ||
assert.Equal(t, "Elasticsearch", eumCallType.Elasticsearch.ToString()) | ||
assert.Equal(t, "Hand", eumCallType.Hand.ToString()) | ||
assert.Equal(t, "KeyLocation", eumCallType.KeyLocation.ToString()) | ||
assert.Equal(t, "Etcd", eumCallType.Etcd.ToString()) | ||
assert.Equal(t, "", eumCallType.Enum(9).ToString()) | ||
|
||
baseTraceDetail := trace.BaseTraceDetail{} | ||
baseTraceDetail.SetSql("", "", "", 0) | ||
baseTraceDetail.Ignore() | ||
assert.Equal(t, true, baseTraceDetail.IsIgnore()) | ||
baseTraceDetail.GetLevel() | ||
testErr(baseTraceDetail) | ||
|
||
// EmptyManager | ||
iManager := container.Resolve[trace.IManager]() | ||
iManager.EntryWebApi("", "", "", "", nil, "", "") | ||
iManager.EntryFSchedule("", 0, 0) | ||
iManager.EntryMqConsumer("", "", "") | ||
iManager.EntryQueueConsumer("") | ||
iManager.EntryTask("") | ||
iManager.EntryWatchKey("") | ||
iManager.TraceMq("", "", "iManager") | ||
iManager.GetCurTrace() | ||
iManager.TraceDatabase() | ||
iManager.TraceDatabaseOpen("", "") | ||
iManager.TraceElasticsearch("", "", "") | ||
iManager.TraceEtcd("", "", 0) | ||
iManager.TraceHand("") | ||
iManager.TraceHttp("", "") | ||
iManager.TraceKeyLocation("") | ||
iManager.TraceMqSend("", "", "", "") | ||
iManager.TraceRedis("", "", "") | ||
|
||
iManager.TraceHand("").ToString() | ||
iManager.TraceHand("").GetTraceDetail() | ||
iManager.TraceHand("").End(nil) | ||
iManager.TraceHand("").Ignore() | ||
iManager.TraceHand("").IsIgnore() | ||
iManager.TraceHand("").GetLevel() | ||
iManager.TraceHand("").SetSql("", "", "", 0) | ||
|
||
iManager.EntryQueueConsumer("").End() | ||
iManager.EntryQueueConsumer("").Ignore() | ||
iManager.EntryQueueConsumer("").GetList() | ||
iManager.EntryQueueConsumer("").GetTraceId() | ||
iManager.EntryQueueConsumer("").AddDetail(nil) | ||
iManager.EntryQueueConsumer("").Error(nil) | ||
iManager.EntryQueueConsumer("").GetStartTs() | ||
iManager.EntryQueueConsumer("").SetBody("", 0, "") | ||
} | ||
|
||
func testErr(baseTraceDetail trace.BaseTraceDetail) { | ||
baseTraceDetail.End(fmt.Errorf("")) | ||
} |
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