Skip to content

Commit

Permalink
Add tests to getters
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Nov 11, 2023
1 parent 98958e5 commit fea056d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions config/getters_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -121,3 +122,27 @@ func TestGetReadHeaderTimeout(t *testing.T) {
metrics := Metrics{}
assert.Equal(t, DefaultReadHeaderTimeout, metrics.GetReadHeaderTimeout())
}

// TestGetTimeout tests the GetTimeout function of the metrics server.
func TestGetTimeout(t *testing.T) {
metrics := Metrics{}
assert.Equal(t, DefaultMetricsServerTimeout, metrics.GetTimeout())
}

// TestFilter tests the Filter function.
func TestFilter(t *testing.T) {
// Load config from the default config file.
conf := NewConfig(context.TODO(), "../gatewayd.yaml", "../gatewayd_plugins.yaml")
conf.InitConfig(context.TODO())
assert.NotEmpty(t, conf.Global)

// Filter the config.
defaultGroup := conf.Global.Filter(Default)
assert.NotEmpty(t, defaultGroup)
assert.Contains(t, defaultGroup.Clients, Default)
assert.Contains(t, defaultGroup.Servers, Default)
assert.Contains(t, defaultGroup.Pools, Default)
assert.Contains(t, defaultGroup.Proxies, Default)
assert.Contains(t, defaultGroup.Metrics, Default)
assert.Contains(t, defaultGroup.Loggers, Default)
}

0 comments on commit fea056d

Please sign in to comment.