From f69df916df341671d602fcc4f2604838b1ea72ec Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Mon, 1 May 2017 09:13:21 -0500 Subject: [PATCH] tpl: Add basic tests for all namespace init funcs --- tpl/cast/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/collections/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/compare/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/crypto/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/data/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/encoding/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/fmt/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/images/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/inflect/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/lang/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/math/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/os/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/partials/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/safe/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/strings/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/time/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/transform/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ tpl/urls/init_test.go | 38 ++++++++++++++++++++++++++++++++++++ 18 files changed, 684 insertions(+) create mode 100644 tpl/cast/init_test.go create mode 100644 tpl/collections/init_test.go create mode 100644 tpl/compare/init_test.go create mode 100644 tpl/crypto/init_test.go create mode 100644 tpl/data/init_test.go create mode 100644 tpl/encoding/init_test.go create mode 100644 tpl/fmt/init_test.go create mode 100644 tpl/images/init_test.go create mode 100644 tpl/inflect/init_test.go create mode 100644 tpl/lang/init_test.go create mode 100644 tpl/math/init_test.go create mode 100644 tpl/os/init_test.go create mode 100644 tpl/partials/init_test.go create mode 100644 tpl/safe/init_test.go create mode 100644 tpl/strings/init_test.go create mode 100644 tpl/time/init_test.go create mode 100644 tpl/transform/init_test.go create mode 100644 tpl/urls/init_test.go diff --git a/tpl/cast/init_test.go b/tpl/cast/init_test.go new file mode 100644 index 000000000..22051495a --- /dev/null +++ b/tpl/cast/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cast + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/collections/init_test.go b/tpl/collections/init_test.go new file mode 100644 index 000000000..1066caeaa --- /dev/null +++ b/tpl/collections/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package collections + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/compare/init_test.go b/tpl/compare/init_test.go new file mode 100644 index 000000000..610c0e5cb --- /dev/null +++ b/tpl/compare/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compare + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/crypto/init_test.go b/tpl/crypto/init_test.go new file mode 100644 index 000000000..20c0201e5 --- /dev/null +++ b/tpl/crypto/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package crypto + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/data/init_test.go b/tpl/data/init_test.go new file mode 100644 index 000000000..f912560c4 --- /dev/null +++ b/tpl/data/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package data + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/encoding/init_test.go b/tpl/encoding/init_test.go new file mode 100644 index 000000000..f10f4b1f8 --- /dev/null +++ b/tpl/encoding/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package encoding + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/fmt/init_test.go b/tpl/fmt/init_test.go new file mode 100644 index 000000000..9b71381d6 --- /dev/null +++ b/tpl/fmt/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fmt + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/images/init_test.go b/tpl/images/init_test.go new file mode 100644 index 000000000..d4fc65484 --- /dev/null +++ b/tpl/images/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package images + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/inflect/init_test.go b/tpl/inflect/init_test.go new file mode 100644 index 000000000..741e8f797 --- /dev/null +++ b/tpl/inflect/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package inflect + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/lang/init_test.go b/tpl/lang/init_test.go new file mode 100644 index 000000000..8a03d18eb --- /dev/null +++ b/tpl/lang/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package lang + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/math/init_test.go b/tpl/math/init_test.go new file mode 100644 index 000000000..70a8e3c96 --- /dev/null +++ b/tpl/math/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package math + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/os/init_test.go b/tpl/os/init_test.go new file mode 100644 index 000000000..53d4c6920 --- /dev/null +++ b/tpl/os/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package os + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/partials/init_test.go b/tpl/partials/init_test.go new file mode 100644 index 000000000..b841f2151 --- /dev/null +++ b/tpl/partials/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package partials + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/safe/init_test.go b/tpl/safe/init_test.go new file mode 100644 index 000000000..e18c5b12c --- /dev/null +++ b/tpl/safe/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package safe + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/strings/init_test.go b/tpl/strings/init_test.go new file mode 100644 index 000000000..5b7616406 --- /dev/null +++ b/tpl/strings/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package strings + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/time/init_test.go b/tpl/time/init_test.go new file mode 100644 index 000000000..a41d8e4f3 --- /dev/null +++ b/tpl/time/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package time + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/transform/init_test.go b/tpl/transform/init_test.go new file mode 100644 index 000000000..26f81d7f1 --- /dev/null +++ b/tpl/transform/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package transform + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +} diff --git a/tpl/urls/init_test.go b/tpl/urls/init_test.go new file mode 100644 index 000000000..f619b2c00 --- /dev/null +++ b/tpl/urls/init_test.go @@ -0,0 +1,38 @@ +// Copyright 2017 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package urls + +import ( + "testing" + + "github.com/spf13/hugo/deps" + "github.com/spf13/hugo/tpl/internal" + "github.com/stretchr/testify/require" +) + +func TestInit(t *testing.T) { + var found bool + var ns *internal.TemplateFuncsNamespace + + for _, nsf := range internal.TemplateFuncsNamespaceRegistry { + ns = nsf(&deps.Deps{}) + if ns.Name == name { + found = true + break + } + } + + require.True(t, found) + require.IsType(t, &Namespace{}, ns.Context.(func() interface{})()) +}