1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00
node-feature-discovery/test_sources.go
Balaji Subramaniam 398deb7cc1 Enabled graceful failure if discovery for a source fails.
- Handles errors from discovery of source.
- Handles panics from discovery of source using recover().
- Added tests.
2016-11-15 16:24:53 -08:00

28 lines
797 B
Go

package main
////////////////////////////////////////////////////////////////////////////////
// Fake Source (used only for testing)
// Implements main.FeatureSource.
type fakeSource struct{}
func (s fakeSource) Name() string { return "fake" }
func (s fakeSource) Discover() ([]string, error) {
features := []string{}
// Adding three fake features.
features = append(features, "fakefeature1", "fakefeature2", "fakefeature3")
return features, nil
}
////////////////////////////////////////////////////////////////////////////////
// Fake Panic Source (used only for testing)
// Implements main.FeatureSource.
type fakePanicSource struct{}
func (s fakePanicSource) Name() string { return "fakepanic" }
func (s fakePanicSource) Discover() ([]string, error) {
panic("fake panic error")
}