-
-
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.
refactoring: context, tests for stackdriver
- Loading branch information
Showing
5 changed files
with
150 additions
and
3 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
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,94 @@ | ||
package exporters | ||
|
||
import ( | ||
"context" | ||
"sync" | ||
|
||
"github.com/hyeoncheon/bogo/internal/common" | ||
) | ||
|
||
type DummyContext struct { | ||
context.Context // nolint | ||
common.Options | ||
cancel context.CancelFunc | ||
ch chan interface{} | ||
wg *sync.WaitGroup | ||
logger common.Logger | ||
meta common.MetaClient | ||
} | ||
|
||
var _ common.Context = &DummyContext{} | ||
|
||
// Cancel implements common.Context. | ||
func (c *DummyContext) Cancel() { | ||
c.cancel() | ||
c.wg.Wait() | ||
close(c.ch) | ||
} | ||
|
||
// Logger implements common.Context. | ||
func (c *DummyContext) Logger() common.Logger { | ||
return c.logger | ||
} | ||
|
||
// Meta implements common.Context. | ||
func (c *DummyContext) Meta() common.MetaClient { | ||
return c.meta | ||
} | ||
|
||
// WG implements common.Context. | ||
func (c *DummyContext) WG() *sync.WaitGroup { | ||
return c.wg | ||
} | ||
|
||
// Channel implements common.Context. | ||
func (c *DummyContext) Channel() chan interface{} { | ||
return c.ch | ||
} | ||
|
||
type DummyMeta struct { | ||
VarExternalIP string | ||
VarInstanceName string | ||
VarWhereAmI string | ||
VarZone string | ||
} | ||
|
||
// AttributeCSV implements common.MetaClient. | ||
func (*DummyMeta) AttributeCSV(_ string) []string { | ||
panic("unimplemented") | ||
} | ||
|
||
// AttributeSSV implements common.MetaClient. | ||
func (*DummyMeta) AttributeSSV(_ string) []string { | ||
panic("unimplemented") | ||
} | ||
|
||
// AttributeValue implements common.MetaClient. | ||
func (*DummyMeta) AttributeValue(_ string) string { | ||
panic("unimplemented") | ||
} | ||
|
||
// AttributeValues implements common.MetaClient. | ||
func (*DummyMeta) AttributeValues(_ string) []string { | ||
panic("unimplemented") | ||
} | ||
|
||
// ExternalIP implements common.MetaClient. | ||
func (m *DummyMeta) ExternalIP() string { | ||
return m.VarExternalIP | ||
} | ||
|
||
// InstanceName implements common.MetaClient. | ||
func (m *DummyMeta) InstanceName() string { | ||
return m.VarInstanceName | ||
} | ||
|
||
// WhereAmI implements common.MetaClient. | ||
func (m *DummyMeta) WhereAmI() string { | ||
return m.VarWhereAmI | ||
} | ||
|
||
// Zone implements common.MetaClient. | ||
func (m *DummyMeta) Zone() string { | ||
return m.VarZone | ||
} |
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