hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

servicesConfig_test.go (1803B)

    1 // Copyright 2018 The Hugo Authors. All rights reserved.
    2 //
    3 // Licensed under the Apache License, Version 2.0 (the "License");
    4 // you may not use this file except in compliance with the License.
    5 // You may obtain a copy of the License at
    6 // http://www.apache.org/licenses/LICENSE-2.0
    7 //
    8 // Unless required by applicable law or agreed to in writing, software
    9 // distributed under the License is distributed on an "AS IS" BASIS,
   10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   11 // See the License for the specific language governing permissions and
   12 // limitations under the License.
   13 
   14 package services
   15 
   16 import (
   17 	"testing"
   18 
   19 	qt "github.com/frankban/quicktest"
   20 	"github.com/gohugoio/hugo/config"
   21 )
   22 
   23 func TestDecodeConfigFromTOML(t *testing.T) {
   24 	c := qt.New(t)
   25 
   26 	tomlConfig := `
   27 
   28 someOtherValue = "foo"
   29 
   30 [services]
   31 [services.disqus]
   32 shortname = "DS"
   33 [services.googleAnalytics]
   34 id = "ga_id"
   35 [services.instagram]
   36 disableInlineCSS = true
   37 [services.twitter]
   38 disableInlineCSS = true
   39 `
   40 	cfg, err := config.FromConfigString(tomlConfig, "toml")
   41 	c.Assert(err, qt.IsNil)
   42 
   43 	config, err := DecodeConfig(cfg)
   44 	c.Assert(err, qt.IsNil)
   45 	c.Assert(config, qt.Not(qt.IsNil))
   46 
   47 	c.Assert(config.Disqus.Shortname, qt.Equals, "DS")
   48 	c.Assert(config.GoogleAnalytics.ID, qt.Equals, "ga_id")
   49 
   50 	c.Assert(config.Instagram.DisableInlineCSS, qt.Equals, true)
   51 }
   52 
   53 // Support old root-level GA settings etc.
   54 func TestUseSettingsFromRootIfSet(t *testing.T) {
   55 	c := qt.New(t)
   56 
   57 	cfg := config.NewWithTestDefaults()
   58 	cfg.Set("disqusShortname", "root_short")
   59 	cfg.Set("googleAnalytics", "ga_root")
   60 
   61 	config, err := DecodeConfig(cfg)
   62 	c.Assert(err, qt.IsNil)
   63 	c.Assert(config, qt.Not(qt.IsNil))
   64 
   65 	c.Assert(config.Disqus.Shortname, qt.Equals, "root_short")
   66 	c.Assert(config.GoogleAnalytics.ID, qt.Equals, "ga_root")
   67 }